contexts

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: MIT Imports: 4 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 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.

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.

func (CRE) LoggerKVs

func (c CRE) LoggerKVs() []any

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