github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/service/registry/client/options.go (about) 1 package client 2 3 import ( 4 "context" 5 6 "github.com/tickoalcantara12/micro/v3/service/client" 7 "github.com/tickoalcantara12/micro/v3/service/registry" 8 ) 9 10 type clientKey struct{} 11 12 // WithClient sets the RPC client 13 func WithClient(c client.Client) registry.Option { 14 return func(o *registry.Options) { 15 if o.Context == nil { 16 o.Context = context.Background() 17 } 18 19 o.Context = context.WithValue(o.Context, clientKey{}, c) 20 } 21 }