Loading documentation...
Loading documentation...
Loading documentation...
Complete API documentation for the memory package.
Import Path: github.com/kolosys/nova/memory
Config configures the EventStore
// Create a new Config
config := Config{
MaxEventsPerStream: 42,
MaxStreams: 42,
RetentionDuration: /* value */,
SnapshotInterval: /* value */,
MetricsCollector: /* value */,
Name: "example",
}type Config struct {
MaxEventsPerStream int64
MaxStreams int
RetentionDuration time.Duration
SnapshotInterval time.Duration
MetricsCollector shared.MetricsCollector
Name string
}| Field | Type | Description |
|---|---|---|
| MaxEventsPerStream | int64 | MaxEventsPerStream limits events per stream (0 = unlimited) |
| MaxStreams | int | MaxStreams limits the number of streams (0 = unlimited) |
| RetentionDuration | time.Duration | RetentionDuration sets how long to keep events (0 = forever) |
| SnapshotInterval | time.Duration | SnapshotInterval sets how often to create snapshots |
| MetricsCollector | shared.MetricsCollector | MetricsCollector for observability (optional) |
| Name | string | Name identifies this store instance |
DefaultConfig returns a sensible default configuration
func DefaultConfig() ConfigParameters: None
Returns:
Cursor represents a position in the event stream
// Create a new Cursor
cursor := Cursor{
StreamID: "example",
Position: 42,
Timestamp: /* value */,
}type Cursor struct {
StreamID string
Position int64
Timestamp time.Time
}| Field | Type | Description |
|---|---|---|
| StreamID | string | StreamID identifies the stream |
| Position | int64 | Position is the sequence number within the stream |
| Timestamp | time.Time | Timestamp is the time of the event at this position |
String returns a string representation of the cursor
func (Cursor) String() stringParameters: None
Returns:
EventStore defines the interface for event storage and replay
// Example implementation of EventStore
type MyEventStore struct {
// Add your fields here
}
func (m MyEventStore) Append(param1 context.Context, param2 string, param3 ...shared.Event) error {
// Implement your logic here
return
}
func (m MyEventStore) Read(param1 context.Context, param2 string, param3 Cursor, param4 int) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) ReadStream(param1 context.Context, param2 string, param3 int64) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) ReadTimeRange(param1 context.Context, param2 time.Time) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) Replay(param1 context.Context, param2 time.Time) <-chan shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) Subscribe(param1 context.Context, param2 string, param3 Cursor) <-chan shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) GetStreams() []StreamInfo {
// Implement your logic here
return
}
func (m MyEventStore) GetStreamInfo(param1 string) StreamInfo {
// Implement your logic here
return
}
func (m MyEventStore) Snapshot(param1 context.Context) error {
// Implement your logic here
return
}
func (m MyEventStore) Close() error {
// Implement your logic here
return
}
func (m MyEventStore) Stats() Stats {
// Implement your logic here
return
}
type EventStore interface {
Append(ctx context.Context, streamID string, events ...shared.Event) error
Read(ctx context.Context, streamID string, cursor Cursor, limit int) ([]shared.Event, Cursor, error)
ReadStream(ctx context.Context, streamID string, fromPosition int64) ([]shared.Event, error)
ReadTimeRange(ctx context.Context, from, to time.Time) ([]shared.Event, error)
Replay(ctx context.Context, from, to time.Time) (<-chan shared.Event, error)
Subscribe(ctx context.Context, streamID string, from Cursor) (<-chan shared.Event, error)
GetStreams() []StreamInfo
GetStreamInfo(streamID string) (StreamInfo, error)
Snapshot(ctx context.Context) error
Close() error
Stats() Stats
}| Method | Description |
|---|
New creates a new in-memory EventStore
func New(config Config) EventStoreParameters:
config (Config)Returns:
Stats provides store statistics
// Create a new Stats
stats := Stats{
TotalEvents: 42,
TotalStreams: 42,
EventsAppended: 42,
EventsRead: 42,
SubscriptionsActive: 42,
SnapshotsCreated: 42,
MemoryUsageBytes: 42,
}type Stats struct {
TotalEvents int64
TotalStreams int64
EventsAppended int64
EventsRead int64
SubscriptionsActive int64
SnapshotsCreated int64
MemoryUsageBytes int64
}| Field | Type | Description |
|---|---|---|
| TotalEvents | int64 | |
| TotalStreams | int64 | |
| EventsAppended | int64 | |
| EventsRead | int64 | |
| SubscriptionsActive | int64 | |
| SnapshotsCreated | int64 | |
| MemoryUsageBytes | int64 |
StreamInfo provides information about a stream
// Create a new StreamInfo
streaminfo := StreamInfo{
StreamID: "example",
EventCount: 42,
FirstEvent: /* value */,
LastEvent: /* value */,
LastPosition: 42,
}type StreamInfo struct {
StreamID string
EventCount int64
FirstEvent time.Time
LastEvent time.Time
LastPosition int64
}| Field | Type | Description |
|---|---|---|
| StreamID | string | |
| EventCount | int64 | |
| FirstEvent | time.Time | |
| LastEvent | time.Time | |
| LastPosition | int64 |
Complete API documentation for the memory package.
Import Path: github.com/kolosys/nova/memory
Config configures the EventStore
// Create a new Config
config := Config{
MaxEventsPerStream: 42,
MaxStreams: 42,
RetentionDuration: /* value */,
SnapshotInterval: /* value */,
MetricsCollector: /* value */,
Name: "example",
}type Config struct {
MaxEventsPerStream int64
MaxStreams int
RetentionDuration time.Duration
SnapshotInterval time.Duration
MetricsCollector shared.MetricsCollector
Name string
}| Field | Type | Description |
|---|---|---|
| MaxEventsPerStream | int64 | MaxEventsPerStream limits events per stream (0 = unlimited) |
| MaxStreams | int | MaxStreams limits the number of streams (0 = unlimited) |
| RetentionDuration | time.Duration | RetentionDuration sets how long to keep events (0 = forever) |
| SnapshotInterval | time.Duration | SnapshotInterval sets how often to create snapshots |
| MetricsCollector | shared.MetricsCollector | MetricsCollector for observability (optional) |
| Name | string | Name identifies this store instance |
DefaultConfig returns a sensible default configuration
func DefaultConfig() ConfigParameters: None
Returns:
Cursor represents a position in the event stream
// Create a new Cursor
cursor := Cursor{
StreamID: "example",
Position: 42,
Timestamp: /* value */,
}type Cursor struct {
StreamID string
Position int64
Timestamp time.Time
}| Field | Type | Description |
|---|---|---|
| StreamID | string | StreamID identifies the stream |
| Position | int64 | Position is the sequence number within the stream |
| Timestamp | time.Time | Timestamp is the time of the event at this position |
String returns a string representation of the cursor
func (Cursor) String() stringParameters: None
Returns:
EventStore defines the interface for event storage and replay
// Example implementation of EventStore
type MyEventStore struct {
// Add your fields here
}
func (m MyEventStore) Append(param1 context.Context, param2 string, param3 ...shared.Event) error {
// Implement your logic here
return
}
func (m MyEventStore) Read(param1 context.Context, param2 string, param3 Cursor, param4 int) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) ReadStream(param1 context.Context, param2 string, param3 int64) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) ReadTimeRange(param1 context.Context, param2 time.Time) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) Replay(param1 context.Context, param2 time.Time) <-chan shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) Subscribe(param1 context.Context, param2 string, param3 Cursor) <-chan shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) GetStreams() []StreamInfo {
// Implement your logic here
return
}
func (m MyEventStore) GetStreamInfo(param1 string) StreamInfo {
// Implement your logic here
return
}
func (m MyEventStore) Snapshot(param1 context.Context) error {
// Implement your logic here
return
}
func (m MyEventStore) Close() error {
// Implement your logic here
return
}
func (m MyEventStore) Stats() Stats {
// Implement your logic here
return
}
type EventStore interface {
Append(ctx context.Context, streamID string, events ...shared.Event) error
Read(ctx context.Context, streamID string, cursor Cursor, limit int) ([]shared.Event, Cursor, error)
ReadStream(ctx context.Context, streamID string, fromPosition int64) ([]shared.Event, error)
ReadTimeRange(ctx context.Context, from, to time.Time) ([]shared.Event, error)
Replay(ctx context.Context, from, to time.Time) (<-chan shared.Event, error)
Subscribe(ctx context.Context, streamID string, from Cursor) (<-chan shared.Event, error)
GetStreams() []StreamInfo
GetStreamInfo(streamID string) (StreamInfo, error)
Snapshot(ctx context.Context) error
Close() error
Stats() Stats
}| Method | Description |
|---|
New creates a new in-memory EventStore
func New(config Config) EventStoreParameters:
config (Config)Returns:
Stats provides store statistics
// Create a new Stats
stats := Stats{
TotalEvents: 42,
TotalStreams: 42,
EventsAppended: 42,
EventsRead: 42,
SubscriptionsActive: 42,
SnapshotsCreated: 42,
MemoryUsageBytes: 42,
}type Stats struct {
TotalEvents int64
TotalStreams int64
EventsAppended int64
EventsRead int64
SubscriptionsActive int64
SnapshotsCreated int64
MemoryUsageBytes int64
}| Field | Type | Description |
|---|---|---|
| TotalEvents | int64 | |
| TotalStreams | int64 | |
| EventsAppended | int64 | |
| EventsRead | int64 | |
| SubscriptionsActive | int64 | |
| SnapshotsCreated | int64 | |
| MemoryUsageBytes | int64 |
StreamInfo provides information about a stream
// Create a new StreamInfo
streaminfo := StreamInfo{
StreamID: "example",
EventCount: 42,
FirstEvent: /* value */,
LastEvent: /* value */,
LastPosition: 42,
}type StreamInfo struct {
StreamID string
EventCount int64
FirstEvent time.Time
LastEvent time.Time
LastPosition int64
}| Field | Type | Description |
|---|---|---|
| StreamID | string | |
| EventCount | int64 | |
| FirstEvent | time.Time | |
| LastEvent | time.Time | |
| LastPosition | int64 |
// Create a new Config
config := Config{
MaxEventsPerStream: 42,
MaxStreams: 42,
RetentionDuration: /* value */,
SnapshotInterval: /* value */,
MetricsCollector: /* value */,
Name: "example",
}type Config struct {
MaxEventsPerStream int64
MaxStreams int
RetentionDuration time.Duration
SnapshotInterval time.Duration
MetricsCollector shared.MetricsCollector
Name string
}func DefaultConfig() Config// Create a new Cursor
cursor := Cursor{
StreamID: "example",
Position: 42,
Timestamp: /* value */,
}type Cursor struct {
StreamID string
Position int64
Timestamp time.Time
}func (Cursor) String() string// Example implementation of EventStore
type MyEventStore struct {
// Add your fields here
}
func (m MyEventStore) Append(param1 context.Context, param2 string, param3 ...shared.Event) error {
// Implement your logic here
return
}
func (m MyEventStore) Read(param1 context.Context, param2 string, param3 Cursor, param4 int) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) ReadStream(param1 context.Context, param2 string, param3 int64) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) ReadTimeRange(param1 context.Context, param2 time.Time) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) Replay(param1 context.Context, param2 time.Time) <-chan shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) Subscribe(param1 context.Context, param2 string, param3 Cursor) <-chan shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) GetStreams() []StreamInfo {
// Implement your logic here
return
}
func (m MyEventStore) GetStreamInfo(param1 string) StreamInfo {
// Implement your logic here
return
}
func (m MyEventStore) Snapshot(param1 context.Context) error {
// Implement your logic here
return
}
func (m MyEventStore) Close() error {
// Implement your logic here
return
}
func (m MyEventStore) Stats() Stats {
// Implement your logic here
return
}
type EventStore interface {
Append(ctx context.Context, streamID string, events ...shared.Event) error
Read(ctx context.Context, streamID string, cursor Cursor, limit int) ([]shared.Event, Cursor, error)
ReadStream(ctx context.Context, streamID string, fromPosition int64) ([]shared.Event, error)
ReadTimeRange(ctx context.Context, from, to time.Time) ([]shared.Event, error)
Replay(ctx context.Context, from, to time.Time) (<-chan shared.Event, error)
Subscribe(ctx context.Context, streamID string, from Cursor) (<-chan shared.Event, error)
GetStreams() []StreamInfo
GetStreamInfo(streamID string) (StreamInfo, error)
Snapshot(ctx context.Context) error
Close() error
Stats() Stats
}func New(config Config) EventStore// Create a new Stats
stats := Stats{
TotalEvents: 42,
TotalStreams: 42,
EventsAppended: 42,
EventsRead: 42,
SubscriptionsActive: 42,
SnapshotsCreated: 42,
MemoryUsageBytes: 42,
}type Stats struct {
TotalEvents int64
TotalStreams int64
EventsAppended int64
EventsRead int64
SubscriptionsActive int64
SnapshotsCreated int64
MemoryUsageBytes int64
}// Create a new StreamInfo
streaminfo := StreamInfo{
StreamID: "example",
EventCount: 42,
FirstEvent: /* value */,
LastEvent: /* value */,
LastPosition: 42,
}type StreamInfo struct {
StreamID string
EventCount int64
FirstEvent time.Time
LastEvent time.Time
LastPosition int64
}// Create a new Config
config := Config{
MaxEventsPerStream: 42,
MaxStreams: 42,
RetentionDuration: /* value */,
SnapshotInterval: /* value */,
MetricsCollector: /* value */,
Name: "example",
}type Config struct {
MaxEventsPerStream int64
MaxStreams int
RetentionDuration time.Duration
SnapshotInterval time.Duration
MetricsCollector shared.MetricsCollector
Name string
}func DefaultConfig() Config// Create a new Cursor
cursor := Cursor{
StreamID: "example",
Position: 42,
Timestamp: /* value */,
}type Cursor struct {
StreamID string
Position int64
Timestamp time.Time
}func (Cursor) String() string// Example implementation of EventStore
type MyEventStore struct {
// Add your fields here
}
func (m MyEventStore) Append(param1 context.Context, param2 string, param3 ...shared.Event) error {
// Implement your logic here
return
}
func (m MyEventStore) Read(param1 context.Context, param2 string, param3 Cursor, param4 int) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) ReadStream(param1 context.Context, param2 string, param3 int64) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) ReadTimeRange(param1 context.Context, param2 time.Time) []shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) Replay(param1 context.Context, param2 time.Time) <-chan shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) Subscribe(param1 context.Context, param2 string, param3 Cursor) <-chan shared.Event {
// Implement your logic here
return
}
func (m MyEventStore) GetStreams() []StreamInfo {
// Implement your logic here
return
}
func (m MyEventStore) GetStreamInfo(param1 string) StreamInfo {
// Implement your logic here
return
}
func (m MyEventStore) Snapshot(param1 context.Context) error {
// Implement your logic here
return
}
func (m MyEventStore) Close() error {
// Implement your logic here
return
}
func (m MyEventStore) Stats() Stats {
// Implement your logic here
return
}
type EventStore interface {
Append(ctx context.Context, streamID string, events ...shared.Event) error
Read(ctx context.Context, streamID string, cursor Cursor, limit int) ([]shared.Event, Cursor, error)
ReadStream(ctx context.Context, streamID string, fromPosition int64) ([]shared.Event, error)
ReadTimeRange(ctx context.Context, from, to time.Time) ([]shared.Event, error)
Replay(ctx context.Context, from, to time.Time) (<-chan shared.Event, error)
Subscribe(ctx context.Context, streamID string, from Cursor) (<-chan shared.Event, error)
GetStreams() []StreamInfo
GetStreamInfo(streamID string) (StreamInfo, error)
Snapshot(ctx context.Context) error
Close() error
Stats() Stats
}func New(config Config) EventStore// Create a new Stats
stats := Stats{
TotalEvents: 42,
TotalStreams: 42,
EventsAppended: 42,
EventsRead: 42,
SubscriptionsActive: 42,
SnapshotsCreated: 42,
MemoryUsageBytes: 42,
}type Stats struct {
TotalEvents int64
TotalStreams int64
EventsAppended int64
EventsRead int64
SubscriptionsActive int64
SnapshotsCreated int64
MemoryUsageBytes int64
}// Create a new StreamInfo
streaminfo := StreamInfo{
StreamID: "example",
EventCount: 42,
FirstEvent: /* value */,
LastEvent: /* value */,
LastPosition: 42,
}type StreamInfo struct {
StreamID string
EventCount int64
FirstEvent time.Time
LastEvent time.Time
LastPosition int64
}