Merge pull request #1024 from unistack-org/server
add server Context option to pass own context
This commit is contained in:
		| @@ -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 | // Registry used for discovery | ||||||
| func Registry(r registry.Registry) Option { | func Registry(r registry.Registry) Option { | ||||||
| 	return func(o *Options) { | 	return func(o *Options) { | ||||||
|   | |||||||
| @@ -126,18 +126,21 @@ func Context(ctx context.Context) Option { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Registry used for discovery | ||||||
| func Registry(r registry.Registry) Option { | func Registry(r registry.Registry) Option { | ||||||
| 	return func(o *Options) { | 	return func(o *Options) { | ||||||
| 		o.Registry = r | 		o.Registry = r | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Register the service with a TTL | ||||||
| func RegisterTTL(t time.Duration) Option { | func RegisterTTL(t time.Duration) Option { | ||||||
| 	return func(o *Options) { | 	return func(o *Options) { | ||||||
| 		o.RegisterTTL = t | 		o.RegisterTTL = t | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Register the service with at interval | ||||||
| func RegisterInterval(t time.Duration) Option { | func RegisterInterval(t time.Duration) Option { | ||||||
| 	return func(o *Options) { | 	return func(o *Options) { | ||||||
| 		o.RegisterInterval = t | 		o.RegisterInterval = t | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user