store

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aggregate

func Aggregate(ctx context.Context, s Interface) error

func AggregateDay

func AggregateDay(ts time.Time, responses []*types.HttpResponse) *types.HttpResponse

func GenerateHistory

func GenerateHistory(s Interface, start time.Time, id string) int

Types

type Bolt

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

func NewBolt

func NewBolt(ctx context.Context, path string) (*Bolt, error)

func (*Bolt) AddIncident

func (b *Bolt) AddIncident(ctx context.Context, hostID string, e *types.Incident) error

func (*Bolt) AddResponse

func (b *Bolt) AddResponse(ctx context.Context, hostID string, r *types.HttpResponse) error

func (*Bolt) Close

func (b *Bolt) Close() error

func (*Bolt) DeleteIncident

func (b *Bolt) DeleteIncident(ctx context.Context, hostID string, eventID int) error

func (*Bolt) DeleteResponse

func (b *Bolt) DeleteResponse(ctx context.Context, hostID string, keys []time.Time) error

func (*Bolt) EndIncident

func (b *Bolt) EndIncident(ctx context.Context, hostID string, eventID int, ts time.Time) error

func (*Bolt) FindIncidents

func (b *Bolt) FindIncidents(ctx context.Context, hostID string, skip, limit int) ([]*types.Incident, error)

func (*Bolt) FindResponses

func (b *Bolt) FindResponses(ctx context.Context, hostID string) ([]*types.HttpResponse, error)

func (*Bolt) Hosts

func (b *Bolt) Hosts(ctx context.Context) ([]string, error)

func (*Bolt) LastResponse

func (b *Bolt) LastResponse(ctx context.Context, hostID string) (*types.HttpResponse, error)

type Interface

type Interface interface {
	// AddResponse adds a new response to the history of the given ID.
	// DeleteResponse deletes the given keys from the history of the given ID.
	// FindResponses returns the history of the given ID.
	AddResponse(ctx context.Context, hostID string, r *types.HttpResponse) error
	DeleteResponse(ctx context.Context, hostID string, keys []time.Time) error
	FindResponses(ctx context.Context, hostID string) ([]*types.HttpResponse, error)
	LastResponse(ctx context.Context, hostID string) (*types.HttpResponse, error)

	// Hosts returns a list of all hosts that has any responses in the store.
	Hosts(ctx context.Context) ([]string, error)

	// AddIncident puts a new incident to the store.
	// EndIncident marks the incident as finished by setting the end time.
	// DeleteIncident removes the incident from the store.
	// FindIncidents returns the list of incidents for the ID.
	AddIncident(ctx context.Context, hostID string, e *types.Incident) error
	EndIncident(ctx context.Context, hostID string, eventID int, ts time.Time) error
	DeleteIncident(ctx context.Context, hostID string, eventID int) error
	FindIncidents(ctx context.Context, hostID string, skip, limit int) ([]*types.Incident, error)

	Close() error
}

func New

func New(ctx context.Context, typ, path string, cfg *types.Cfg) (Interface, error)

type Memory

type Memory struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMemory

func NewMemory(ctx context.Context) *Memory

func (*Memory) AddIncident

func (m *Memory) AddIncident(ctx context.Context, hostID string, e *types.Incident) error

func (*Memory) AddResponse

func (m *Memory) AddResponse(ctx context.Context, hostID string, r *types.HttpResponse) error

func (*Memory) Close

func (m *Memory) Close() error

func (*Memory) DeleteIncident

func (m *Memory) DeleteIncident(ctx context.Context, hostID string, eventID int) error

func (*Memory) DeleteResponse

func (m *Memory) DeleteResponse(ctx context.Context, hostID string, keys []time.Time) error

func (*Memory) EndIncident

func (m *Memory) EndIncident(ctx context.Context, hostID string, eventID int, ts time.Time) error

func (*Memory) FindIncidents

func (m *Memory) FindIncidents(ctx context.Context, hostID string, skip, limit int) ([]*types.Incident, error)

func (*Memory) FindResponses

func (m *Memory) FindResponses(ctx context.Context, hostID string) ([]*types.HttpResponse, error)

func (*Memory) Hosts

func (m *Memory) Hosts(ctx context.Context) ([]string, error)

func (*Memory) LastResponse

func (m *Memory) LastResponse(ctx context.Context, hostID string) (*types.HttpResponse, error)

Jump to

Keyboard shortcuts

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