Documentation
¶
Index ¶
- Variables
- func DialGRPC(endpoint string) (*grpc.ClientConn, error)
- func DialGRPCWithConfig(endpoint string, cfg GRPCDialConfig) (*grpc.ClientConn, error)
- type BackgroundErrorSource
- type BootstrapProcessor
- type Checkpoint
- type CheckpointClient
- type CheckpointLease
- type Config
- type EventClient
- type EventEnvelope
- type EventProcessor
- type EventStream
- type GRPCAuth
- type GRPCCheckpointClient
- func (c GRPCCheckpointClient) AcquireLease(ctx context.Context, clientID string, ttl time.Duration) (CheckpointLease, error)
- func (c GRPCCheckpointClient) Get(ctx context.Context, clientID string) (Checkpoint, error)
- func (c GRPCCheckpointClient) Put(ctx context.Context, clientID, contentType string, value json.RawMessage) (Checkpoint, error)
- func (c GRPCCheckpointClient) PutCAS(ctx context.Context, clientID, contentType string, value json.RawMessage, ...) (Checkpoint, error)
- func (c GRPCCheckpointClient) ReleaseLease(ctx context.Context, clientID, leaseToken string) error
- func (c GRPCCheckpointClient) RenewLease(ctx context.Context, clientID, leaseToken string, ttl time.Duration) (CheckpointLease, error)
- type GRPCDialConfig
- type GRPCEventClient
- type LeaseGenerationConsumer
- type LeasedCheckpointClient
- type Runtime
- type SubscribeRequest
Constants ¶
This section is empty.
Variables ¶
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.
func DialGRPCWithConfig ¶ added in v0.3.0
func DialGRPCWithConfig(endpoint string, cfg GRPCDialConfig) (*grpc.ClientConn, error)
Types ¶
type BackgroundErrorSource ¶ added in v0.3.0
type BackgroundErrorSource interface {
BackgroundErrors() <-chan error
}
BackgroundErrorSource reports terminal asynchronous failures that must stop processing before any more events or checkpoints are committed.
type BootstrapProcessor ¶ added in v0.3.0
type BootstrapProcessor interface {
Bootstrap(ctx context.Context, events EventClient, save func(context.Context) error) (afterCursor string, err error)
}
BootstrapProcessor performs a restartable current-state scan after the checkpoint lease is acquired and before live replay begins. save persists the processor's current scan token using the active lease.
type Checkpoint ¶
type Checkpoint struct {
ClientID string
ContentType string
Value json.RawMessage
Revision string
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 CheckpointLease ¶ added in v0.3.0
type Config ¶
type Config struct {
ClientID string
Kinds []string
EntryChannels []string
EntryContentTypes []string
EntryRoles []string
Scope string
AfterCursor string
Justification string
Detail string
CheckpointInterval time.Duration
ReconnectMin time.Duration
ReconnectMax time.Duration
LeaseTTL time.Duration
OnReady func(bool)
}
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
Change 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 GRPCCheckpointClient ¶
type GRPCCheckpointClient struct {
Client pb.AdminCheckpointServiceClient
Auth GRPCAuth
}
GRPCCheckpointClient adapts AdminCheckpointService to CheckpointClient.
func (GRPCCheckpointClient) AcquireLease ¶ added in v0.3.0
func (c GRPCCheckpointClient) AcquireLease(ctx context.Context, clientID string, ttl time.Duration) (CheckpointLease, error)
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.
func (GRPCCheckpointClient) PutCAS ¶ added in v0.3.0
func (c GRPCCheckpointClient) PutCAS(ctx context.Context, clientID, contentType string, value json.RawMessage, expectedRevision, leaseToken string) (Checkpoint, error)
func (GRPCCheckpointClient) ReleaseLease ¶ added in v0.3.0
func (c GRPCCheckpointClient) ReleaseLease(ctx context.Context, clientID, leaseToken string) error
func (GRPCCheckpointClient) RenewLease ¶ added in v0.3.0
func (c GRPCCheckpointClient) RenewLease(ctx context.Context, clientID, leaseToken string, ttl time.Duration) (CheckpointLease, error)
type GRPCDialConfig ¶ added in v0.3.0
type GRPCDialConfig struct {
TLS bool
CAFile string
AllowInsecure bool
// MaxReceiveBytes raises the default receive allowance when a processor
// accepts individual records larger than the service default.
MaxReceiveBytes int
}
GRPCDialConfig applies the processor transport policy. Remote plaintext is rejected unless the caller explicitly marks the connection as development-only.
type GRPCEventClient ¶
type GRPCEventClient struct {
Client pb.EventStreamServiceClient
Auth GRPCAuth
}
GRPCEventClient adapts EventStreamService to EventClient.
func (GRPCEventClient) Subscribe ¶
func (c GRPCEventClient) Subscribe(ctx context.Context, req SubscribeRequest) (EventStream, error)
Subscribe opens a gRPC event stream.
type LeaseGenerationConsumer ¶ added in v0.3.0
LeaseGenerationConsumer receives the fencing generation before event processing starts.
type LeasedCheckpointClient ¶ added in v0.3.0
type LeasedCheckpointClient interface {
CheckpointClient
PutCAS(ctx context.Context, clientID, contentType string, value json.RawMessage, expectedRevision, leaseToken string) (Checkpoint, error)
AcquireLease(ctx context.Context, clientID string, ttl time.Duration) (CheckpointLease, error)
RenewLease(ctx context.Context, clientID, leaseToken string, ttl time.Duration) (CheckpointLease, error)
ReleaseLease(ctx context.Context, clientID, leaseToken string) error
}
LeasedCheckpointClient adds compare-and-swap ownership for processors that require one active replica per checkpoint.
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.