Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: unistack-org/micro
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.2.17
Choose a base ref
...
head repository: unistack-org/micro
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.2.18
Choose a head ref
  • 1 commit
  • 65 files changed
  • 1 contributor

Commits on Mar 6, 2021

  1. fieldalignment of all structs to save memory

    Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
    vtolstov committed Mar 6, 2021
    Copy the full SHA
    bbbcb22 View commit details
Showing with 651 additions and 655 deletions.
  1. +5 −5 api/api.go
  2. +2 −2 api/handler/options.go
  3. +5 −2 api/resolver/options.go
  4. +8 −3 api/router/options.go
  5. +15 −17 auth/auth.go
  6. +30 −40 auth/options.go
  7. +9 −10 broker/memory.go
  8. +26 −31 broker/options.go
  9. +2 −2 build/build.go
  10. +2 −2 client/noop.go
  11. +62 −56 client/options.go
  12. +4 −4 client/test_request.go
  13. +4 −6 codec/codec.go
  14. +7 −3 codec/options.go
  15. +22 −16 config/options.go
  16. +7 −3 errors/errors.go
  17. +1 −1 logger/micro.go
  18. +10 −9 logger/options.go
  19. +2 −2 metadata/metadata.go
  20. +18 −9 meter/options.go
  21. +2 −2 meter/wrapper/wrapper.go
  22. +12 −12 network/options.go
  23. +13 −18 network/transport/memory.go
  24. +23 −31 network/transport/options.go
  25. +5 −6 network/tunnel/broker/broker.go
  26. +16 −15 network/tunnel/options.go
  27. +35 −24 options.go
  28. +1 −1 profiler/http/http.go
  29. +3 −7 profiler/pprof/pprof.go
  30. +10 −10 proxy/options.go
  31. +4 −4 register/memory.go
  32. +17 −19 register/options.go
  33. +2 −2 register/register.go
  34. +8 −5 register/watcher.go
  35. +2 −2 resolver/dns/dns.go
  36. +7 −15 router/options.go
  37. +4 −4 router/route.go
  38. +5 −5 router/watcher.go
  39. +25 −56 runtime/options.go
  40. +14 −9 runtime/runtime.go
  41. +2 −2 server/handler.go
  42. +3 −3 server/noop.go
  43. +65 −47 server/options.go
  44. +3 −3 server/request.go
  45. +4 −4 server/subscriber.go
  46. +52 −41 store/options.go
  47. +5 −6 sync/memory.go
  48. +9 −3 sync/options.go
  49. +1 −1 tracer/noop.go
  50. +2 −2 tracer/options.go
  51. +7 −7 tracer/tracer.go
  52. +2 −2 tracer/wrapper/wrapper.go
  53. +7 −8 util/pki/certoptions.go
  54. +6 −7 util/pool/default.go
  55. +5 −6 util/ring/buffer.go
  56. +10 −16 util/router/compile.go
  57. +1 −1 util/router/router.go
  58. +2 −3 util/router/runtime.go
  59. +1 −1 util/router/types.go
  60. +1 −1 util/socket/pool.go
  61. +4 −9 util/socket/socket.go
  62. +1 −2 util/stream/stream.go
  63. +2 −2 util/sync/sync.go
  64. +3 −4 util/token/jwt/jwt.go
  65. +4 −4 util/token/token.go
10 changes: 5 additions & 5 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -34,20 +34,20 @@ type Option func(*Options) error
type Endpoint struct {
// Name Greeter.Hello
Name string
// Description e.g what's this endpoint for
// Desciption for endpoint
Description string
// Handler e.g rpc, proxy
Handler string
// Body destination
// "*" or "" - top level message value
// "string" - inner message value
Body string
// Host e.g example.com
Host []string
// Method e.g GET, POST
Method []string
// Path e.g /greeter. Expect POSIX regex
Path []string
// Body destination
// "*" or "" - top level message value
// "string" - inner message value
Body string
// Stream flag
Stream bool
}
4 changes: 2 additions & 2 deletions api/handler/options.go
Original file line number Diff line number Diff line change
@@ -13,11 +13,11 @@ var (

// Options struct holds handler options
type Options struct {
MaxRecvSize int64
Namespace string
Router router.Router
Client client.Client
Logger logger.Logger
Namespace string
MaxRecvSize int64
}

// Option func signature
7 changes: 5 additions & 2 deletions api/resolver/options.go
Original file line number Diff line number Diff line change
@@ -8,9 +8,12 @@ import (

// Options struct
type Options struct {
Handler string
// Context is for external defined options
Context context.Context
// Handler name
Handler string
// ServicePrefix is the prefix
ServicePrefix string
Context context.Context
}

// Option func
11 changes: 8 additions & 3 deletions api/router/options.go
Original file line number Diff line number Diff line change
@@ -11,11 +11,16 @@ import (

// Options holds the options for api router
type Options struct {
Handler string
// Register for service lookup
Register register.Register
// Resolver to use
Resolver resolver.Resolver
Logger logger.Logger
Context context.Context
// Logger micro logger
Logger logger.Logger
// Context is for external options
Context context.Context
// Handler name
Handler string
}

// Option func signature
32 changes: 15 additions & 17 deletions auth/auth.go
Original file line number Diff line number Diff line change
@@ -53,30 +53,30 @@ type Auth interface {

// Account provided by an auth provider
type Account struct {
// ID of the account e.g. email
// Metadata any other associated metadata
Metadata metadata.Metadata `json:"metadata"`
// ID of the account e.g. email or uuid
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 metadata.Metadata `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
@@ -106,17 +106,15 @@ const (

// Rule is used to verify access to a resource
type Rule struct {
// ID of the rule, e.g. "public"
// Resource that rule belongs to
Resource *Resource
// ID of the rule
ID string
// Scope the rule requires, a blank scope indicates open to the public and * indicates the rule
// applies to any valid account
// Scope of the rule
Scope string
// Resource the rule applies to
Resource *Resource
// Access determines if the rule grants or denies access to the resource
// Access flag allow/deny
Access Access
// Priority the rule should take when verifying a request, the higher the value the sooner the
// rule will be applied
// Priority holds the rule priority
Priority int32
}

70 changes: 30 additions & 40 deletions auth/options.go
Original file line number Diff line number Diff line change
@@ -26,33 +26,34 @@ func NewOptions(opts ...Option) Options {

// Options struct holds auth options
type Options struct {
Name string
// Issuer of the service's account
Issuer string
// ID is the services auth ID
ID string
// Secret is used to authenticate the service
Secret string
// Context holds the external options
Context context.Context
// Meter used for metrics
Meter meter.Meter
// Logger used for logging
Logger logger.Logger
// Tracer used for tracing
Tracer tracer.Tracer
// Store used for stre data
Store store.Store
// Token is the services token used to authenticate itself
Token *Token
// PublicKey for decoding JWTs
PublicKey string
// PrivateKey for encoding JWTs
PrivateKey string
// LoginURL is the relative url path where a user can login
LoginURL string
// Store to back auth
Store store.Store
// PrivateKey for encoding JWTs
PrivateKey string
// PublicKey for decoding JWTs
PublicKey string
// Secret is used to authenticate the service
Secret string
// ID is the services auth ID
ID string
// Issuer of the service's account
Issuer string
// Name holds the auth name
Name string
// Addrs sets the addresses of auth
Addrs []string
// Logger sets the logger
Logger logger.Logger
// Meter sets tht meter
Meter meter.Meter
// Tracer
Tracer tracer.Tracer
// Context to store other options
Context context.Context
}

// Option func
@@ -124,18 +125,12 @@ func LoginURL(url string) Option {

// GenerateOptions struct
type GenerateOptions struct {
// Metadata associated with the account
Metadata metadata.Metadata
// 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
// Issuer of the account, e.g. micro
Issuer string
Type string
Secret string
Issuer string
Scopes []string
}

// GenerateOption func
@@ -194,16 +189,11 @@ func NewGenerateOptions(opts ...GenerateOption) GenerateOptions {

// TokenOptions struct
type TokenOptions struct {
// ID for the account
ID string
// Secret for the account
Secret string
// RefreshToken is used to refesh a token
ID string
Secret string
RefreshToken string
// Expiry is the time the token should live for
Expiry time.Duration
// Issuer of the account
Issuer string
Issuer string
Expiry time.Duration
}

// TokenOption func
19 changes: 9 additions & 10 deletions broker/memory.go
Original file line number Diff line number Diff line change
@@ -13,28 +13,27 @@ import (
)

type memoryBroker struct {
opts Options

addr string
sync.RWMutex
connected bool
opts Options
Subscribers map[string][]*memorySubscriber
addr string
sync.RWMutex
connected bool
}

type memoryEvent struct {
opts Options
topic string
err error
message interface{}
topic string
}

type memorySubscriber struct {
id string
topic string
exit chan bool
handler Handler
opts SubscribeOptions
ctx context.Context
exit chan bool
handler Handler
id string
topic string
}

func (m *memoryBroker) Options() Options {
57 changes: 26 additions & 31 deletions broker/options.go
Original file line number Diff line number Diff line change
@@ -13,25 +13,26 @@ import (

// Options struct
type Options struct {
Name string
// Addrs useed by broker
Addrs []string
// ErrorHandler executed when errors occur processing messages
ErrorHandler Handler
// Codec used to marshal/unmarshal messages
// Tracer used for tracing
Tracer tracer.Tracer
// Register can be used for clustering
Register register.Register
// Codec holds the codec for marshal/unmarshal
Codec codec.Codec
// Logger the used logger
// Logger used for logging
Logger logger.Logger
// Meter the used for metrics
// Meter used for metrics
Meter meter.Meter
// Tracer used for trace
Tracer tracer.Tracer
// TLSConfig for secure communication
TLSConfig *tls.Config
// Register used for clustering
Register register.Register
// Context is used for non default options
// Context holds external options
Context context.Context
// TLSConfig holds tls.TLSConfig options
TLSConfig *tls.Config
// ErrorHandler used when broker can't unmarshal incoming message
ErrorHandler Handler
// Name holds the broker name
Name string
// Addrs holds the broker address
Addrs []string
}

// NewOptions create new Options
@@ -59,10 +60,10 @@ func Context(ctx context.Context) Option {

// PublishOptions struct
type PublishOptions struct {
// BodyOnly says that only body of the message must be published
BodyOnly bool
// Context for non default options
// Context holds external options
Context context.Context
// BodyOnly flag says the message contains raw body bytes
BodyOnly bool
}

// NewPublishOptions creates PublishOptions struct
@@ -80,22 +81,16 @@ func NewPublishOptions(opts ...PublishOption) PublishOptions {

// SubscribeOptions struct
type SubscribeOptions struct {
// AutoAck ack messages if handler returns nil err
AutoAck bool

// ErrorHandler executed when errors occur processing messages
// Context holds external options
Context context.Context
// ErrorHandler used when broker can't unmarshal incoming message
ErrorHandler Handler

// Group for subscriber, Subscribers with the same group name
// will create a shared subscription where each
// receives a subset of messages.
// Group holds consumer group
Group string

// BodyOnly says that consumed only body of the message
// AutoAck flag specifies auto ack of incoming message when no error happens
AutoAck bool
// BodyOnly flag specifies that message contains only body bytes without header
BodyOnly bool

// Context is used for non default options
Context context.Context
}

// Option func
4 changes: 2 additions & 2 deletions build/build.go
Original file line number Diff line number Diff line change
@@ -21,12 +21,12 @@ type Source struct {

// Package is packaged format for source
type Package struct {
// Source of the package
Source *Source
// Name of the package
Name string
// Location of the package
Path string
// Type of package e.g tarball, binary, docker
Type string
// Source of the package
Source *Source
}
4 changes: 2 additions & 2 deletions client/noop.go
Original file line number Diff line number Diff line change
@@ -31,12 +31,12 @@ type noopMessage struct {
}

type noopRequest struct {
body interface{}
codec codec.Codec
service string
method string
endpoint string
contentType string
body interface{}
codec codec.Codec
stream bool
}

Loading