stream

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxBufferedBytes int64 = 1 << 20

Variables

View Source
var (
	ErrNotFound      = errors.New("plugin stream not found")
	ErrInvalidStream = errors.New("plugin stream is invalid")
	ErrStreamClosed  = errors.New("plugin stream is closed")
	ErrBackpressure  = errors.New("plugin stream backpressure limit exceeded")
)

Functions

This section is empty.

Types

type AppendRequest

type AppendRequest struct {
	StreamID string    `json:"stream_id"`
	Kind     string    `json:"kind,omitempty"`
	Data     []byte    `json:"data,omitempty"`
	Error    string    `json:"error,omitempty"`
	Now      time.Time `json:"now,omitempty"`
}

type CloseRequest

type CloseRequest struct {
	StreamID string    `json:"stream_id"`
	Status   Status    `json:"status,omitempty"`
	Reason   string    `json:"reason,omitempty"`
	Now      time.Time `json:"now,omitempty"`
}

type Direction

type Direction string
const (
	DirectionRead   Direction = "read"
	DirectionWrite  Direction = "write"
	DirectionDuplex Direction = "duplex"
)

type Event

type Event struct {
	StreamID string    `json:"stream_id"`
	Sequence uint64    `json:"sequence"`
	Kind     string    `json:"kind"`
	Data     []byte    `json:"data,omitempty"`
	Error    string    `json:"error,omitempty"`
	At       time.Time `json:"at"`
}

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Append

func (s *MemoryStore) Append(_ context.Context, req AppendRequest) (Event, error)

func (*MemoryStore) Close

func (s *MemoryStore) Close(_ context.Context, req CloseRequest) (Record, error)

func (*MemoryStore) Get

func (s *MemoryStore) Get(_ context.Context, streamID string) (Record, error)

func (*MemoryStore) MarkPluginTransition

func (s *MemoryStore) MarkPluginTransition(_ context.Context, req PluginTransitionRequest) ([]Record, error)

func (*MemoryStore) Read

func (s *MemoryStore) Read(_ context.Context, req ReadRequest) (Record, []Event, error)

func (*MemoryStore) Register

func (s *MemoryStore) Register(_ context.Context, req RegisterRequest) (Record, error)

type PluginTransitionRequest

type PluginTransitionRequest struct {
	PluginInstanceID string    `json:"plugin_instance_id"`
	Status           Status    `json:"status"`
	Now              time.Time `json:"now,omitempty"`
}

type ReadRequest

type ReadRequest struct {
	StreamID  string `json:"stream_id"`
	MaxEvents int    `json:"max_events,omitempty"`
	MaxBytes  int64  `json:"max_bytes,omitempty"`
}

type Record

type Record struct {
	StreamID             string     `json:"stream_id"`
	PluginID             string     `json:"plugin_id"`
	PluginInstanceID     string     `json:"plugin_instance_id"`
	Method               string     `json:"method"`
	Effect               string     `json:"effect,omitempty"`
	Execution            string     `json:"execution"`
	SurfaceInstanceID    string     `json:"surface_instance_id,omitempty"`
	OwnerSessionHash     string     `json:"owner_session_hash,omitempty"`
	OwnerUserHash        string     `json:"owner_user_hash,omitempty"`
	SessionChannelIDHash string     `json:"session_channel_id_hash,omitempty"`
	BridgeChannelID      string     `json:"bridge_channel_id,omitempty"`
	Direction            Direction  `json:"direction"`
	Status               Status     `json:"status"`
	ContentType          string     `json:"content_type,omitempty"`
	MaxBufferedBytes     int64      `json:"max_buffered_bytes,omitempty"`
	BufferedBytes        int64      `json:"buffered_bytes,omitempty"`
	CreatedAt            time.Time  `json:"created_at"`
	UpdatedAt            time.Time  `json:"updated_at"`
	ClosedAt             *time.Time `json:"closed_at,omitempty"`
}

type RegisterRequest

type RegisterRequest struct {
	StreamID             string    `json:"stream_id"`
	PluginID             string    `json:"plugin_id"`
	PluginInstanceID     string    `json:"plugin_instance_id"`
	Method               string    `json:"method"`
	Effect               string    `json:"effect,omitempty"`
	Execution            string    `json:"execution"`
	SurfaceInstanceID    string    `json:"surface_instance_id,omitempty"`
	OwnerSessionHash     string    `json:"owner_session_hash,omitempty"`
	OwnerUserHash        string    `json:"owner_user_hash,omitempty"`
	SessionChannelIDHash string    `json:"session_channel_id_hash,omitempty"`
	BridgeChannelID      string    `json:"bridge_channel_id,omitempty"`
	Direction            Direction `json:"direction,omitempty"`
	ContentType          string    `json:"content_type,omitempty"`
	MaxBufferedBytes     int64     `json:"max_buffered_bytes,omitempty"`
	Now                  time.Time `json:"now,omitempty"`
}

type SQLiteStore

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

func NewSQLiteStore

func NewSQLiteStore(ctx context.Context, path string) (*SQLiteStore, error)

func (*SQLiteStore) Append

func (s *SQLiteStore) Append(ctx context.Context, req AppendRequest) (Event, error)

func (*SQLiteStore) Close

func (s *SQLiteStore) Close(ctx context.Context, req CloseRequest) (Record, error)

func (*SQLiteStore) CloseDatabase

func (s *SQLiteStore) CloseDatabase() error

func (*SQLiteStore) Get

func (s *SQLiteStore) Get(ctx context.Context, streamID string) (Record, error)

func (*SQLiteStore) MarkPluginTransition

func (s *SQLiteStore) MarkPluginTransition(ctx context.Context, req PluginTransitionRequest) ([]Record, error)

func (*SQLiteStore) Read

func (s *SQLiteStore) Read(ctx context.Context, req ReadRequest) (Record, []Event, error)

func (*SQLiteStore) Register

func (s *SQLiteStore) Register(ctx context.Context, req RegisterRequest) (Record, error)

type Status

type Status string
const (
	StatusOpen             Status = "open"
	StatusClosed           Status = "closed"
	StatusCanceled         Status = "canceled"
	StatusOrphanedDisabled Status = "orphaned_after_disable"
	StatusOrphanedRemoved  Status = "orphaned_after_uninstall"
)

type Store

type Store interface {
	Register(ctx context.Context, req RegisterRequest) (Record, error)
	Get(ctx context.Context, streamID string) (Record, error)
	Append(ctx context.Context, req AppendRequest) (Event, error)
	Read(ctx context.Context, req ReadRequest) (Record, []Event, error)
	Close(ctx context.Context, req CloseRequest) (Record, error)
	MarkPluginTransition(ctx context.Context, req PluginTransitionRequest) ([]Record, error)
}

Jump to

Keyboard shortcuts

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