contexts

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CREStreamInterceptor

func CREStreamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)

CREStreamInterceptor is a grpc.StreamInterceptor that converts CRE context values to GRPC metadata.

func CREUnaryInterceptor

func CREUnaryInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

CREUnaryInterceptor is a grpc.UnaryInterceptor that converts CRE context values to GRPC metadata.

func ChainSelectorValue added in v0.9.7

func ChainSelectorValue(ctx context.Context) (uint64, error)

ChainSelectorValue returns the chain selector, if one was set via WithChainSelector.

func Value

func Value[T any](ctx context.Context, key any) T

Value gets a value from the context and casts it to T.

func WithCRE

func WithCRE(ctx context.Context, cre CRE) context.Context

WithCRE returns a derived context with a cre key/val. The values will be normalized via CRE.Normalized.

func WithChainSelector added in v0.9.7

func WithChainSelector(ctx context.Context, cs uint64) context.Context

WithChainSelector returns a new context that includes the chain selector. Use ChainSelectorValue to get the value.

Types

type CRE

type CRE struct {
	Org             string // may be missing even if others are present.
	Owner, Workflow string
}

CRE holds contextual Chainlink Runtime Environment metadata. This can include organization, owner, and workflow information. When a value is present, the higher scoped values are normally also available - except for Org, which may not be set. Typically injected via context.Context. See WithCRE & CREValue.

func CREValue

func CREValue(ctx context.Context) CRE

CREValue returns the CRE key/val, which may be empty. If it is not empty, the values will be normalized.

func (CRE) LoggerKVs

func (c CRE) LoggerKVs() []any

func (CRE) Normalized added in v0.9.0

func (c CRE) Normalized() CRE

Normalized returns a possibly modified CRE with normalized values.

type CREServerInterceptor

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

CREServerInterceptor has methods that implement grpc.UnaryServerInterceptor and grpc.StreamServerInterceptor

func NewCREServerInterceptor

func NewCREServerInterceptor(lggr logger.Logger) *CREServerInterceptor

func (*CREServerInterceptor) StreamServerInterceptor

func (i *CREServerInterceptor) StreamServerInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamServerInterceptor is a grpc.StreamServerInterceptor that converts GRPC metadata to CRE context values.

func (*CREServerInterceptor) UnaryServerInterceptor

func (i *CREServerInterceptor) UnaryServerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error)

UnaryServerInterceptor is a grpc.UnaryServerInterceptor that converts GRPC metadata to CRE context values.

Jump to

Keyboard shortcuts

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