Skip to content

Commit

Permalink
Merge pull request micro#1024 from unistack-org/server
Browse files Browse the repository at this point in the history
add server Context option to pass own context
  • Loading branch information
asim committed Dec 17, 2019
2 parents 6027a81 + 1c5a4c4 commit 4e02f44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ func Codec(contentType string, c codec.NewCodec) Option {
}
}

// Context specifies a context for the service.
// Can be used to signal shutdown of the service
// Can be used for extra option values.
func Context(ctx context.Context) Option {
return func(o *Options) {
o.Context = ctx
}
}

// Registry used for discovery
func Registry(r registry.Registry) Option {
return func(o *Options) {
Expand Down
3 changes: 3 additions & 0 deletions web/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,21 @@ func Context(ctx context.Context) Option {
}
}

// Registry used for discovery
func Registry(r registry.Registry) Option {
return func(o *Options) {
o.Registry = r
}
}

// Register the service with a TTL
func RegisterTTL(t time.Duration) Option {
return func(o *Options) {
o.RegisterTTL = t
}
}

// Register the service with at interval
func RegisterInterval(t time.Duration) Option {
return func(o *Options) {
o.RegisterInterval = t
Expand Down

0 comments on commit 4e02f44

Please sign in to comment.