Documentation
¶
Index ¶
- type Compactor
- type Cursor
- type Event
- type Logger
- type Manager
- type Option
- type Querier
- type Service
- func (l *Service) Close() error
- func (l *Service) Compact(ctx context.Context, value time.Time) error
- func (l *Service) Log(text string, actors ...uint32) error
- func (l *Service) Page(ctx context.Context, from, to time.Time, cursor Cursor, limit int, ...) ([]Event, Cursor, error)
- func (l *Service) Scan(ctx context.Context, from, to time.Time, actors ...uint32) iter.Seq2[Event, error]
- func (l *Service) Sync(ctx context.Context) error
- type Syncer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶ added in v0.3.0
type Cursor string
Cursor is an opaque URL-safe position in Tales' deterministic event order. Reuse it with the same time range and actors.
const Zero Cursor = ""
Zero starts paging at the first event in the requested direction.
type Event ¶ added in v0.2.0
Event is a validated log event. Its projections are zero-copy and read-only; use Clone before retaining or modifying their backing data.
type Option ¶
type Option func(*config)
Option configures the Service. All options are optional and may be provided to New when constructing a logger.
func WithBuffer ¶
WithBuffer sets the maximum number of entries kept in memory.
func WithClient ¶
WithClient allows overriding the S3 client creation function.
func WithInterval ¶
WithInterval sets the interval at which in-memory chunks are flushed.
func WithKey ¶
func WithKey(key *aws.SigningKey) Option
WithKey sets the signing key to use for the S3 client.
func WithPrefix ¶
WithPrefix sets the S3 key prefix to use when storing objects.
func WithWriterID ¶ added in v0.2.0
WithWriterID hashes a stable name into the service's 16-character writer ID.
type Querier ¶ added in v0.0.2
type Querier interface {
Page(context.Context, time.Time, time.Time, Cursor, int, ...uint32) ([]Event, Cursor, error)
Scan(context.Context, time.Time, time.Time, ...uint32) iter.Seq2[Event, error]
}
Querier reads events in deterministic order.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a distributed S3-backed event log owned by one writer ID.
func (*Service) Close ¶
Close syncs pending events and releases the service after a successful flush.
func (*Service) Compact ¶ added in v0.2.0
Compact commits an immutable merged index for an eligible historical UTC day.
func (*Service) Page ¶ added in v0.3.0
func (l *Service) Page(ctx context.Context, from, to time.Time, cursor Cursor, limit int, actors ...uint32) ([]Event, Cursor, error)
Page returns at most limit matching events from one inclusive bound toward the other, ascending when from <= to and descending otherwise. The cursor is exclusive; an empty next cursor ends iteration.
Example ¶
var log *Service
ctx := context.Background()
start, now := time.Now().Add(-time.Hour), time.Now()
actors := []uint32{42}
var cursor Cursor
for {
events, next, err := log.Page(ctx, now, start, cursor, 50, actors...)
if err != nil {
return
}
for _, event := range events { // Newest first: now toward start.
_ = event.Bytes()
}
if next == Zero {
break
}
cursor = next // Reuse with the same bounds and actors.
}