Skip to content

Commit

Permalink
fix: struct field alignment (micro#2632)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszraczylo committed Apr 26, 2023
1 parent 0f9b2f0 commit a7522e7
Show file tree
Hide file tree
Showing 113 changed files with 678 additions and 621 deletions.
4 changes: 2 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ type Api interface {

// Options are API options.
type Options struct {
// Address of the server
Address string
// Router for resolving routes
Router router.Router
// Client to use for RPC
Client client.Client
// Address of the server
Address string
}

// Option type are API option args.
Expand Down
8 changes: 4 additions & 4 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ type Request struct {
// Response is the response of the generic `api-client` call.
type Response struct {
// json and base64 encoded response body
Body string `json:"body"`
// error fields. Error json example
// {"id":"go.micro.client","code":500,"detail":"malformed method name: \"\"","status":"Internal Server Error"}
Code int `json:"code"`
Body string `json:"body"`
ID string `json:"id"`
Detail string `json:"detail"`
Status string `json:"status"`
// error fields. Error json example
// {"id":"go.micro.client","code":500,"detail":"malformed method name: \"\"","status":"Internal Server Error"}
Code int `json:"code"`
}

// Client enables generic calls to micro.
Expand Down
4 changes: 2 additions & 2 deletions api/handler/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ var (

// Options is the list of api Options.
type Options struct {
MaxRecvSize int64
Namespace string
Router router.Router
Client client.Client
Logger logger.Logger
Namespace string
MaxRecvSize int64
}

// Option is a api Option.
Expand Down
2 changes: 1 addition & 1 deletion api/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type Endpoint struct {

// Options is a struct of available options.
type Options struct {
Handler string
Namespace func(*http.Request) string
Handler string
}

// Option is a helper for a single option.
Expand Down
2 changes: 1 addition & 1 deletion api/router/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

// Options is a struct of options available.
type Options struct {
Handler string
Registry registry.Registry
Resolver resolver.Resolver
Logger logger.Logger
Handler string
}

// Option is a helper for a single options.
Expand Down
7 changes: 4 additions & 3 deletions api/router/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ type endpoint struct {

// router is the default router.
type registryRouter struct {
exit chan bool
opts router.Options

// registry cache
rc cache.Cache

sync.RWMutex
eps map[string]*router.Route
exit chan bool
eps map[string]*router.Route
// compiled regexp for host and path
ceps map[string]*endpoint

sync.RWMutex
}

func (r *registryRouter) isStopped() bool {
Expand Down
4 changes: 2 additions & 2 deletions api/router/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ type endpoint struct {

// Router is the default router.
type Router struct {
exit chan bool
opts router.Options
exit chan bool
eps map[string]*endpoint
sync.RWMutex
eps map[string]*endpoint
}

func (r *Router) isStopd() bool {
Expand Down
17 changes: 9 additions & 8 deletions api/router/util/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ const (

// Template is a compiled representation of path templates.
type Template struct {
// Version is the version number of the format.
Version int
// Verb is a VERB part in the template.
Verb string
// Original template (example: /v1/a_bit_of_everything)
Template string
// OpCodes is a sequence of operations.
OpCodes []int
// Pool is a constant pool
Pool []string
// Verb is a VERB part in the template.
Verb string
// Fields is a list of field paths bound in this template.
Fields []string
// Original template (example: /v1/a_bit_of_everything)
Template string
// Version is the version number of the format.
Version int
}

// Compiler compiles utilities representation of path templates into marshallable operations.
Expand All @@ -30,13 +30,14 @@ type Compiler interface {
}

type op struct {
// code is the opcode of the operation
code OpCode

// str is a string operand of the code.
// operand is ignored if str is not empty.
str string

// code is the opcode of the operation
code OpCode

// operand is a numeric operand of the code.
operand int
}
Expand Down
2 changes: 1 addition & 1 deletion api/router/util/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ func tokenize(path string) (tokens []string, verb string) {

// parser is a parser of the template syntax defined in github.com/googleapis/googleapis/google/api/http.proto.
type parser struct {
logger log.Logger
tokens []string
accepted []string
logger log.Logger
}

// topLevelSegments is the target of this parser.
Expand Down
6 changes: 3 additions & 3 deletions api/router/util/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type rop struct {

// Pattern is a template pattern of http request paths defined in github.com/googleapis/googleapis/google/api/http.proto.
type Pattern struct {
// verb is the VERB part of the path pattern. It is empty if the pattern does not have VERB part.
verb string
// ops is a list of operations
ops []rop
// pool is a constant pool indexed by the operands or vars.
Expand All @@ -34,16 +36,14 @@ type Pattern struct {
stacksize int
// tailLen is the length of the fixed-size segments after a deep wildcard
tailLen int
// verb is the VERB part of the path pattern. It is empty if the pattern does not have VERB part.
verb string
// assumeColonVerb indicates whether a path suffix after a final
// colon may only be interpreted as a verb.
assumeColonVerb bool
}

type patternOptions struct {
assumeColonVerb bool
logger log.Logger
assumeColonVerb bool
}

// PatternOpt is an option for creating Patterns.
Expand Down
2 changes: 1 addition & 1 deletion api/router/util/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
)

type template struct {
segments []segment
verb string
template string
segments []segment
}

type segment interface {
Expand Down
16 changes: 8 additions & 8 deletions api/server/acme/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ type Option func(o *Options)

// Options represents various options you can present to ACME providers.
type Options struct {
// AcceptTLS must be set to true to indicate that you have read your
// provider's terms of service.
AcceptToS bool
// CA is the CA to use
CA string
// ChallengeProvider is a go-acme/lego challenge provider. Set this if you
// want to use DNS Challenges. Otherwise, tls-alpn-01 will be used
ChallengeProvider challenge.Provider
// Issue certificates for domains on demand. Otherwise, certs will be
// retrieved / issued on start-up.
OnDemand bool
// Cache is a storage interface. Most ACME libraries have an cache, but
// there's no defined interface, so if you consume this option
// sanity check it before using.
Cache interface{}

// Logger is the underling logging framework
Logger logger.Logger
// CA is the CA to use
CA string
// AcceptTLS must be set to true to indicate that you have read your
// provider's terms of service.
AcceptToS bool
// Issue certificates for domains on demand. Otherwise, certs will be
// retrieved / issued on start-up.
OnDemand bool
}

// AcceptToS indicates whether you accept your CA's terms of service.
Expand Down
2 changes: 1 addition & 1 deletion api/server/cors/cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

type Config struct {
AllowOrigin string
AllowCredentials bool
AllowMethods string
AllowHeaders string
AllowCredentials bool
}

// CombinedCORSHandler wraps a server and provides CORS headers.
Expand Down
7 changes: 4 additions & 3 deletions api/server/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import (
)

type httpServer struct {
mux *http.ServeMux
opts server.Options

mtx sync.RWMutex
address string
mux *http.ServeMux
exit chan chan error
address string

mtx sync.RWMutex
}

func NewServer(address string, opts ...server.Option) server.Server {
Expand Down
14 changes: 7 additions & 7 deletions api/server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import (
type Option func(o *Options)

type Options struct {
EnableACME bool
EnableCORS bool
CORSConfig *cors.Config
ACMEProvider acme.Provider
EnableTLS bool
ACMEHosts []string
TLSConfig *tls.Config
Resolver resolver.Resolver
Wrappers []Wrapper
Logger logger.Logger
CORSConfig *cors.Config
TLSConfig *tls.Config
ACMEHosts []string
Wrappers []Wrapper
EnableACME bool
EnableCORS bool
EnableTLS bool
}

type Wrapper func(h http.Handler) http.Handler
Expand Down
20 changes: 10 additions & 10 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,30 @@ type Rules interface {

// Account provided by an auth provider.
type Account struct {
// Any other associated metadata
Metadata map[string]string `json:"metadata"`
// ID of the account e.g. email
ID string `json:"id"`
// Type of the account, e.g. service
Type string `json:"type"`
// Issuer of the account
Issuer string `json:"issuer"`
// Any other associated metadata
Metadata map[string]string `json:"metadata"`
// Scopes the account has access to
Scopes []string `json:"scopes"`
// Secret for the account, e.g. the password
Secret string `json:"secret"`
// Scopes the account has access to
Scopes []string `json:"scopes"`
}

// Token can be short or long lived.
type Token struct {
// The token to be used for accessing resources
AccessToken string `json:"access_token"`
// RefreshToken to be used to generate a new token
RefreshToken string `json:"refresh_token"`
// Time of token creation
Created time.Time `json:"created"`
// Time of token expiry
Expiry time.Time `json:"expiry"`
// The token to be used for accessing resources
AccessToken string `json:"access_token"`
// RefreshToken to be used to generate a new token
RefreshToken string `json:"refresh_token"`
}

// Expired returns a boolean indicating if the token needs to be refreshed.
Expand Down Expand Up @@ -106,13 +106,13 @@ const (

// Rule is used to verify access to a resource.
type Rule struct {
// Resource the rule applies to
Resource *Resource
// ID of the rule, e.g. "public"
ID string
// Scope the rule requires, a blank scope indicates open to the public and * indicates the rule
// applies to any valid account
Scope string
// Resource the rule applies to
Resource *Resource
// Access determines if the rule grants or denies access to the resource
Access Access
// Priority the rule should take when verifying a request, the higher the value the sooner the
Expand Down
12 changes: 6 additions & 6 deletions auth/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ func NewOptions(opts ...Option) Options {
}

type Options struct {
// Logger is the underline logger
Logger logger.Logger
// Token is the services token used to authenticate itself
Token *Token
// Namespace the service belongs to
Namespace string
// ID is the services auth ID
ID string
// Secret is used to authenticate the service
Secret string
// Token is the services token used to authenticate itself
Token *Token
// PublicKey for decoding JWTs
PublicKey string
// PrivateKey for encoding JWTs
PrivateKey string
// Addrs sets the addresses of auth
Addrs []string
// Logger is the underline logger
Logger logger.Logger
}

type Option func(o *Options)
Expand Down Expand Up @@ -93,14 +93,14 @@ func ClientToken(token *Token) Option {
type GenerateOptions struct {
// Metadata associated with the account
Metadata map[string]string
// Scopes the account has access too
Scopes []string
// Provider of the account, e.g. oauth
Provider string
// Type of the account, e.g. user
Type string
// Secret used to authenticate the account
Secret string
// Scopes the account has access too
Scopes []string
}

type GenerateOption func(o *GenerateOptions)
Expand Down
Loading

0 comments on commit a7522e7

Please sign in to comment.