eventslog

package module
v0.0.0-...-2af46a5 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EventsLogError = func(errorType string) prometheus.Counter {
		return eventsLogError.WithLabelValues(errorType)
	}
)

Functions

func RedisError

func RedisError(err error) string

Types

type ActorEvent

type ActorEvent struct {
	EventType EventType
	Level     Level
	ActorId   string
	Event     any
	Timestamp time.Time
}

type ClickhouseEventsLog

type ClickhouseEventsLog struct {
	sync.Mutex
	appbase.Service
	// contains filtered or unexported fields
}

func (*ClickhouseEventsLog) Close

func (r *ClickhouseEventsLog) Close() error

func (*ClickhouseEventsLog) GetEvents

func (r *ClickhouseEventsLog) GetEvents(eventType EventType, actorId string, level string, filter *EventsLogFilter, limit int) ([]EventsLogRecord, error)

func (*ClickhouseEventsLog) PostAsync

func (r *ClickhouseEventsLog) PostAsync(event *ActorEvent)

func (*ClickhouseEventsLog) PostEvent

func (r *ClickhouseEventsLog) PostEvent(event *ActorEvent) (id EventsLogRecordId, err error)

func (*ClickhouseEventsLog) Start

func (r *ClickhouseEventsLog) Start()

type DummyEventsLogService

type DummyEventsLogService struct{}

func (*DummyEventsLogService) Close

func (d *DummyEventsLogService) Close() error

func (*DummyEventsLogService) GetEvents

func (d *DummyEventsLogService) GetEvents(eventType EventType, actorId string, level string, filter *EventsLogFilter, limit int) ([]EventsLogRecord, error)

func (*DummyEventsLogService) PostAsync

func (d *DummyEventsLogService) PostAsync(_ *ActorEvent)

func (*DummyEventsLogService) PostEvent

func (d *DummyEventsLogService) PostEvent(_ *ActorEvent) (id EventsLogRecordId, err error)

type EventStatus

type EventStatus string

type EventType

type EventType string
const (
	EventTypeIncoming  EventType = "incoming"
	EventTypeProcessed EventType = "bulker_stream"
	EventTypeBatch     EventType = "bulker_batch"
)

type EventsLogConfig

type EventsLogConfig struct {
	ClickhouseHost     string `mapstructure:"CLICKHOUSE_HOST"`
	ClickhouseDatabase string `mapstructure:"CLICKHOUSE_DATABASE"`
	ClickhouseUsername string `mapstructure:"CLICKHOUSE_USERNAME"`
	ClickhousePassword string `mapstructure:"CLICKHOUSE_PASSWORD"`
	ClickhouseSSL      bool   `mapstructure:"CLICKHOUSE_SSL"`
}

func (*EventsLogConfig) PostInit

func (e *EventsLogConfig) PostInit(settings *appbase.AppSettings) error

type EventsLogFilter

type EventsLogFilter struct {
	Start    time.Time
	End      time.Time
	BeforeId EventsLogRecordId
	Filter   func(event any) bool
}

func (*EventsLogFilter) GetStartAndEndIds

func (f *EventsLogFilter) GetStartAndEndIds() (start, end string, err error)

GetStartAndEndIds returns end and start ids for the stream

type EventsLogRecord

type EventsLogRecord struct {
	Id      EventsLogRecordId `json:"id"`
	Date    time.Time         `json:"date"`
	Content any               `json:"content"`
}

type EventsLogRecordId

type EventsLogRecordId string

type EventsLogService

type EventsLogService interface {
	io.Closer
	// PostEvent posts event to the events log
	// actorId – id of entity of event origin. E.g. for 'incoming' event - id of site, for 'processed' event - id of destination
	PostEvent(event *ActorEvent) (id EventsLogRecordId, err error)

	PostAsync(event *ActorEvent)

	GetEvents(eventType EventType, actorId string, level string, filter *EventsLogFilter, limit int) ([]EventsLogRecord, error)
}

func NewClickhouseEventsLog

func NewClickhouseEventsLog(config EventsLogConfig) (EventsLogService, error)

func NewRedisEventsLog

func NewRedisEventsLog(redisUrl, redisTLSCA string, maxLogSize int) (EventsLogService, error)

type Level

type Level string
const (
	LevelInfo    Level = "info"
	LevelWarning Level = "warn"
	LevelError   Level = "error"
	LevelDebug   Level = "debug"
)

type MultiEventsLogService

type MultiEventsLogService struct {
	Services []EventsLogService
}

func (*MultiEventsLogService) Close

func (m *MultiEventsLogService) Close() error

func (*MultiEventsLogService) GetEvents

func (m *MultiEventsLogService) GetEvents(eventType EventType, actorId string, level string, filter *EventsLogFilter, limit int) ([]EventsLogRecord, error)

func (*MultiEventsLogService) PostAsync

func (m *MultiEventsLogService) PostAsync(event *ActorEvent)

func (*MultiEventsLogService) PostEvent

func (m *MultiEventsLogService) PostEvent(event *ActorEvent) (id EventsLogRecordId, err error)

type RedisEventsLog

type RedisEventsLog struct {
	sync.Mutex
	appbase.Service
	// contains filtered or unexported fields
}

func (*RedisEventsLog) Close

func (r *RedisEventsLog) Close() error

func (*RedisEventsLog) GetEvents

func (r *RedisEventsLog) GetEvents(eventType EventType, actorId string, level string, filter *EventsLogFilter, limit int) ([]EventsLogRecord, error)

func (*RedisEventsLog) PostAsync

func (r *RedisEventsLog) PostAsync(event *ActorEvent)

func (*RedisEventsLog) PostEvent

func (r *RedisEventsLog) PostEvent(event *ActorEvent) (id EventsLogRecordId, err error)

func (*RedisEventsLog) Start

func (r *RedisEventsLog) Start()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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