runtime

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCheckpointNotFound = errors.New("checkpoint not found")

ErrCheckpointNotFound marks a missing checkpoint.

Functions

func DialGRPC

func DialGRPC(endpoint string) (*grpc.ClientConn, error)

DialGRPC opens a Memory Service gRPC connection.

Types

type Checkpoint

type Checkpoint struct {
	ClientID    string
	ContentType string
	Value       json.RawMessage
	UpdatedAt   time.Time
}

Checkpoint is a stored processor checkpoint.

type CheckpointClient

type CheckpointClient interface {
	Get(ctx context.Context, clientID string) (Checkpoint, error)
	Put(ctx context.Context, clientID, contentType string, value json.RawMessage) (Checkpoint, error)
}

CheckpointClient persists one processor checkpoint.

type Config

type Config struct {
	ClientID           string
	Kinds              []string
	EntryChannels      []string
	EntryContentTypes  []string
	EntryRoles         []string
	Scope              string
	AfterCursor        string
	Justification      string
	CheckpointInterval time.Duration
	ReconnectMin       time.Duration
	ReconnectMax       time.Duration
}

Config controls the shared checkpointed stream loop.

type EventClient

type EventClient interface {
	Subscribe(ctx context.Context, req SubscribeRequest) (EventStream, error)
}

EventClient subscribes to Memory Service events.

type EventEnvelope

type EventEnvelope struct {
	Event  string
	Kind   string
	Data   json.RawMessage
	Cursor string
	Time   time.Time
}

EventEnvelope is the normalized event shape consumed by processors.

type EventProcessor

type EventProcessor interface {
	ContentType() string
	Load(state json.RawMessage) error
	Handle(ctx context.Context, event EventEnvelope) error
	Snapshot() (json.RawMessage, error)
	Flush(ctx context.Context) error
}

EventProcessor handles events and exposes a small durable checkpoint payload.

type EventStream

type EventStream interface {
	Recv() (EventEnvelope, error)
}

EventStream opens a durable event stream.

type GRPCAuth

type GRPCAuth struct {
	APIKey      string
	BearerToken string
	ClientID    string
}

GRPCAuth configures Memory Service gRPC request metadata.

type GRPCCheckpointClient

type GRPCCheckpointClient struct {
	Client pb.AdminCheckpointServiceClient
	Auth   GRPCAuth
}

GRPCCheckpointClient adapts AdminCheckpointService to CheckpointClient.

func (GRPCCheckpointClient) Get

func (c GRPCCheckpointClient) Get(ctx context.Context, clientID string) (Checkpoint, error)

Get loads a checkpoint.

func (GRPCCheckpointClient) Put

func (c GRPCCheckpointClient) Put(ctx context.Context, clientID, contentType string, value json.RawMessage) (Checkpoint, error)

Put stores a checkpoint.

type GRPCEventClient

type GRPCEventClient struct {
	Client pb.EventStreamServiceClient
	Auth   GRPCAuth
}

GRPCEventClient adapts EventStreamService to EventClient.

func (GRPCEventClient) Subscribe

Subscribe opens a gRPC event stream.

type Runtime

type Runtime struct {
	Events      EventClient
	Checkpoints CheckpointClient
	Processor   EventProcessor
	Config      Config
	// contains filtered or unexported fields
}

Runtime runs an EventProcessor against a checkpointed event stream.

func (*Runtime) Run

func (r *Runtime) Run(ctx context.Context) error

Run loads checkpoint state, subscribes to events, dispatches them to the processor, and persists checkpoint snapshots after safe progress.

type SubscribeRequest

type SubscribeRequest struct {
	Kinds             []string
	Detail            string
	AfterCursor       string
	Scope             string
	Justification     string
	EntryChannels     []string
	EntryContentTypes []string
	EntryRoles        []string
}

SubscribeRequest is the runtime's transport-independent event request.

Jump to

Keyboard shortcuts

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