sdk

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxResponseSizeBytes = 5 * 1024 * 1024 // 5 MB
	ResponseBufferTooSmall      = "response buffer too small"
	// proto encoder outputs a map with these keys so that user payload can be easily extracted
	ConsensusResponseMapKeyMetadata = "metadata"
	ConsensusResponseMapKeyPayload  = "payload"
)

Variables

This section is empty.

Functions

func ConsensusCommonPrefixAggregation

func ConsensusCommonPrefixAggregation[T any]() func() (ConsensusAggregation[[]T], error)

func ConsensusCommonSuffixAggregation

func ConsensusCommonSuffixAggregation[T any]() func() (ConsensusAggregation[[]T], error)

func DonModeCallInNodeMode

func DonModeCallInNodeMode() error

func NodeModeCallInDonMode

func NodeModeCallInDonMode() error

func ParseJSON

func ParseJSON[T any](bytes []byte) (*T, error)

Types

type CapabilityPromise

type CapabilityPromise interface {
	// contains filtered or unexported methods
}

type ConsensusAggregation

type ConsensusAggregation[T any] interface {
	Descriptor() *pb.ConsensusDescriptor
	Default() *T
	Err() error
	WithDefault(t T) ConsensusAggregation[T]
}

func ConsensusAggregationFromTags

func ConsensusAggregationFromTags[T any]() ConsensusAggregation[T]

func ConsensusIdenticalAggregation

func ConsensusIdenticalAggregation[T any]() ConsensusAggregation[T]

func ConsensusMedianAggregation

func ConsensusMedianAggregation[T NumericType]() ConsensusAggregation[T]

type Environment

type Environment[C any] struct {
	NodeEnvironment[C]
	SecretsProvider
}

type ExecutionHandler

type ExecutionHandler[C, R any] interface {
	CapabilityID() string
	Method() string
	TriggerCfg() *anypb.Any
	Callback() func(env *Environment[C], runtime R, payload *anypb.Any) (any, error)
}

ExecutionHandler is meant to be used internally by the SDK to define workflows.

func Handler

func Handler[C any, M proto.Message, T any, O any](trigger Trigger[M, T], callback func(env *Environment[C], runtime Runtime, payload T) (O, error)) ExecutionHandler[C, Runtime]

type NodeEnvironment

type NodeEnvironment[C any] struct {
	Config    C
	LogWriter io.Writer
	Logger    *slog.Logger
}

type NodeRuntime

type NodeRuntime interface {
	RuntimeBase
	IsNodeRuntime()
}

NodeRuntime is not thread safe and must not be used concurrently.

type NumericType

type NumericType interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64 | *big.Int | decimal.Decimal
}

type Primitive

type Primitive interface {
	NumericType | string | bool
}

type Promise

type Promise[T any] interface {
	Await() (T, error)
	CapabilityPromise
}

func NewBasicPromise

func NewBasicPromise[T any](await func() (T, error)) Promise[T]

func PromiseFromResult

func PromiseFromResult[T any](result T, err error) Promise[T]

func RunInNodeMode

func RunInNodeMode[C, T any](
	env *Environment[C],
	runtime Runtime,
	fn func(env *NodeEnvironment[C], nodeRuntime NodeRuntime) (T, error),
	cd ConsensusAggregation[T]) Promise[T]

func Then

func Then[I, O any](p Promise[I], fn func(I) (O, error)) Promise[O]

type Runner

type Runner[C any] interface {
	Run(initFn func(env *Environment[C]) (Workflow[C], error))
}

type Runtime

type Runtime interface {
	RuntimeBase

	// RunInNodeMode is meant to be used by the helper method RunInNodeMode
	RunInNodeMode(fn func(nodeRuntime NodeRuntime) *pb.SimpleConsensusInputs) Promise[values.Value]
}

Runtime is not thread safe and must not be used concurrently.

type RuntimeBase

type RuntimeBase interface {
	// CallCapability is meant to be called by generated code
	CallCapability(request *pb.CapabilityRequest) Promise[*pb.CapabilityResponse]
	Rand() (*rand.Rand, error)
}

RuntimeBase is not thread safe and must not be used concurrently.

type SecretsProvider

type SecretsProvider interface {
	GetSecret(*sdkpb.SecretRequest) Promise[*sdkpb.Secret]
}

type Trigger

type Trigger[M proto.Message, T any] interface {
	Adapt(m M) (T, error)
	// contains filtered or unexported methods
}

type Workflow

type Workflow[C any] []ExecutionHandler[C, Runtime]

Directories

Path Synopsis
pb module

Jump to

Keyboard shortcuts

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