context

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendServiceContext

func AppendServiceContext(ctx context.Context, svcCtx *ServiceContext) context.Context

AppendServiceContext adds all ServiceContext key-values inside the current context.

func AppendValue

func AppendValue(ctx context.Context, key, value string) context.Context

AppendValue adds a new key-value pair inside the current context.

Types

type Options

type Options struct {
	Name service.Name `validate:"required"`
}

type ServiceContext

type ServiceContext struct {
	// contains filtered or unexported fields
}

ServiceContext is an object that is stored inside a service RPC/HTTP handler context.Context in order to provide information at all source levels, such as, the logger.

func FromContext

func FromContext(ctx context.Context) (*ServiceContext, bool)

FromContext retrieves a ServiceContext from the current context.

func New

func New(options *Options) (*ServiceContext, error)

func (*ServiceContext) Add

func (s *ServiceContext) Add(key, value string)

Add adds a new key-value value pair inside the ServiceContext object.

func (*ServiceContext) Get

func (s *ServiceContext) Get(key string) (string, bool)

Get retrieves a value stored inside the current ServiceContext.

func (*ServiceContext) Values

func (s *ServiceContext) Values() map[string]string

Values gives a copy of the internal key-value ServiceContext container.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL