bboltStorage

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PubTypeEndpoint PubType = "endpoint"
	PubTypeRequest  PubType = "request"
	PubTypeSchedule PubType = "schedule"
	PubTypeStat     PubType = "stat"

	PubVerbCreate PubVerb = "create"
	PubVerbUpdate PubVerb = "update"
	// Marks the item as deleted in the database, but does not delete it
	PubVerbSoftDelete PubVerb = "soft-delete"
	// Removes all items permanently
	PubVerbClean PubVerb = "clean"
)

Variables

View Source
var (
	ErrMissingIdArg = errors.New("Missing id as argument")
	ErrNotFound     = errors.New("Not found")
)
View Source
var (
	BucketEndpoints = []byte("endpoints")
	BucketRequests  = []byte("requests")
	BucketSchedules = []byte("schedules")
	BucketStats     = []byte("stats")
)

Functions

func ForceNewEntity

func ForceNewEntity() (types.Entity, error)

Returns an entity for use by database, with id set and createdAt to current time. It is guaranteeed to be created correctly, if if it errors. The error should be logged.

Types

type BBolter

type BBolter struct {
	*bolt.DB

	Marshaller
	// contains filtered or unexported fields
}

func NewBbolt

func NewBbolt(l logger.AppLogger, path string, pubsub PubSubPublisher) (bb BBolter, err error)

Caller must call close when ending

func (*BBolter) CleanCompactStats

func (s *BBolter) CleanCompactStats() error

func (*BBolter) CompactStats

func (s *BBolter) CompactStats() (es map[string]types.StatEntity, err error)

func (*BBolter) CreateCompactStats

func (s *BBolter) CreateCompactStats(id string, createAt time.Time, p types.StatPayload) error

func (*BBolter) CreateEndpoint

func (s *BBolter) CreateEndpoint(p types.EndpointPayload) (types.EndpointEntity, error)

func (*BBolter) CreateRequest

func (s *BBolter) CreateRequest(p types.RequestPayload) (types.RequestEntity, error)

func (*BBolter) CreateSchedule

func (s *BBolter) CreateSchedule(p types.SchedulePayload) (types.ScheduleEntity, error)

func (*BBolter) Endpoint

func (s *BBolter) Endpoint(id string) (e types.EndpointEntity, err error)

func (*BBolter) Endpoints

func (s *BBolter) Endpoints() (es map[string]types.EndpointEntity, err error)

func (*BBolter) GetItem

func (s *BBolter) GetItem(bucket []byte, id string, j interface{}) error

func (*BBolter) NewEntity

func (s *BBolter) NewEntity() types.Entity

func (*BBolter) PublishChange added in v0.3.0

func (s *BBolter) PublishChange(kind PubType, variant PubVerb, contents interface{})

func (*BBolter) Request

func (s *BBolter) Request(id string) (e types.RequestEntity, err error)

func (*BBolter) Requests

func (s *BBolter) Requests() (es map[string]types.RequestEntity, err error)

func (*BBolter) Schedule

func (s *BBolter) Schedule(id string) (e types.ScheduleEntity, err error)

func (*BBolter) Schedules

func (s *BBolter) Schedules() (es map[string]types.ScheduleEntity, err error)

func (*BBolter) Size

func (s *BBolter) Size() (int64, error)

func (*BBolter) SoftDeleteEndpoint

func (s *BBolter) SoftDeleteEndpoint(id string) (j types.EndpointEntity, err error)

func (*BBolter) SoftDeleteRequest added in v0.4.0

func (s *BBolter) SoftDeleteRequest(id string) (j types.RequestEntity, err error)

func (*BBolter) SoftDeleteSchedule added in v0.4.0

func (s *BBolter) SoftDeleteSchedule(id string) (j types.ScheduleEntity, err error)

func (*BBolter) UpdateCompactStats

func (s *BBolter) UpdateCompactStats(id string, createdAt time.Time, p types.StatPayload) error

func (*BBolter) UpdateEndpoint

func (s *BBolter) UpdateEndpoint(id string, p types.EndpointPayload) (types.EndpointEntity, error)

func (*BBolter) UpdateRequest added in v0.4.0

func (s *BBolter) UpdateRequest(id string, p types.RequestPayload) (types.RequestEntity, error)

func (*BBolter) UpdateSchedule

func (s *BBolter) UpdateSchedule(id string, p types.Schedule) (types.ScheduleEntity, error)

type Gob

type Gob struct{}

func (Gob) Marshal

func (g Gob) Marshal(j interface{}) ([]byte, error)

func (Gob) Unmarshal

func (g Gob) Unmarshal(data []byte, v interface{}) error

type Marshaller

type Marshaller interface {
	Unmarshal(data []byte, v interface{}) error
	Marshal(j interface{}) ([]byte, error)
}

type PubSubPublisher added in v0.3.0

type PubSubPublisher interface {
	Publish(kind, variant string, contents interface{})
}

type PubType added in v0.3.0

type PubType string

type PubVerb added in v0.3.0

type PubVerb string

Jump to

Keyboard shortcuts

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