Skip to content

Commit

Permalink
add server Context option to pass own context
Browse files Browse the repository at this point in the history
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
  • Loading branch information
vtolstov committed Dec 5, 2019
1 parent 18cf025 commit 1c5a4c4
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 1c5a4c4

Please sign in to comment.