mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
d94936f6c9
* v3 * revert plugins * fixup some issues
51 lines
852 B
Go
51 lines
852 B
Go
package source
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/asim/go-micro/v3/client"
|
|
"github.com/asim/go-micro/v3/config/encoder"
|
|
"github.com/asim/go-micro/v3/config/encoder/json"
|
|
)
|
|
|
|
type Options struct {
|
|
// Encoder
|
|
Encoder encoder.Encoder
|
|
|
|
// for alternative data
|
|
Context context.Context
|
|
|
|
// Client to use for RPC
|
|
Client client.Client
|
|
}
|
|
|
|
type Option func(o *Options)
|
|
|
|
func NewOptions(opts ...Option) Options {
|
|
options := Options{
|
|
Encoder: json.NewEncoder(),
|
|
Context: context.Background(),
|
|
Client: client.DefaultClient,
|
|
}
|
|
|
|
for _, o := range opts {
|
|
o(&options)
|
|
}
|
|
|
|
return options
|
|
}
|
|
|
|
// WithEncoder sets the source encoder
|
|
func WithEncoder(e encoder.Encoder) Option {
|
|
return func(o *Options) {
|
|
o.Encoder = e
|
|
}
|
|
}
|
|
|
|
// WithClient sets the source client
|
|
func WithClient(c client.Client) Option {
|
|
return func(o *Options) {
|
|
o.Client = c
|
|
}
|
|
}
|