github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/service/router/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/router"
     8  )
     9  
    10  type clientKey struct{}
    11  
    12  // Client to call router service
    13  func Client(c client.Client) router.Option {
    14  	return func(o *router.Options) {
    15  		if o.Context == nil {
    16  			o.Context = context.WithValue(context.Background(), clientKey{}, c)
    17  			return
    18  		}
    19  
    20  		o.Context = context.WithValue(o.Context, clientKey{}, c)
    21  	}
    22  }