Documentation ¶
Overview ¶
Package storers contains code for storing various data used in the system
Index ¶
- Variables
- func Int64ToTs(i int64) *timestamppb.Timestamp
- func StringPtr(s string) *string
- func TimeToUint64(t *time.Time) uint64
- func TsToInt64(ts *timestamppb.Timestamp) int64
- func TsToUInt64(ts *timestamppb.Timestamp) uint64
- func TsToUInt64Ptr(ts *timestamppb.Timestamp) *uint64
- type ItemStorer
- type NoteStorer
- type StatusStorer
- type StatusThingStorer
- type UserStorer
Constants ¶
This section is empty.
Variables ¶
var DefaultStatuses = []*v1.Status{ {Id: func() string { return ksuid.New().String() }(), Name: "UP", Kind: v1.StatusKind_STATUS_KIND_UP, Color: green}, {Id: func() string { return ksuid.New().String() }(), Name: "DOWN", Kind: v1.StatusKind_STATUS_KIND_DOWN, Color: red}, {Id: func() string { return ksuid.New().String() }(), Name: "WARNING", Kind: v1.StatusKind_STATUS_KIND_WARNING, Color: yellow}, {Id: func() string { return ksuid.New().String() }(), Name: "CREATED", Kind: v1.StatusKind_STATUS_KIND_CREATED, Color: green}, {Id: func() string { return ksuid.New().String() }(), Name: "OFFLINE", Kind: v1.StatusKind_STATUS_KIND_OFFLINE, Color: red}, {Id: func() string { return ksuid.New().String() }(), Name: "ONLINE", Kind: v1.StatusKind_STATUS_KIND_ONLINE, Color: green}, {Id: func() string { return ksuid.New().String() }(), Name: "OBSERVING", Kind: v1.StatusKind_STATUS_KIND_OBSERVING, Color: yellow}, {Id: func() string { return ksuid.New().String() }(), Name: "INVESTIGATING", Kind: v1.StatusKind_STATUS_KIND_INVESTIGATING, Color: yellow}, }
DefaultStatuses are safe default values that can be populated
Functions ¶
func Int64ToTs ¶
func Int64ToTs(i int64) *timestamppb.Timestamp
Int64ToTs - Consistent datastore -> timestamp mapping
func StringPtr ¶
StringPtr returns a string ptr as pointers must be to addressables and we don't want to have to create variables for this kind of stuff these are used in place of sql.Null* types
func TimeToUint64 ¶
TimeToUint64 converts a time.Time to uint64
func TsToInt64 ¶
func TsToInt64(ts *timestamppb.Timestamp) int64
TsToInt64 - Consistent timestamp -> datastore mapping
func TsToUInt64 ¶
func TsToUInt64(ts *timestamppb.Timestamp) uint64
TsToUInt64 returns a timestamppb.Timestamp as a uint64
func TsToUInt64Ptr ¶
func TsToUInt64Ptr(ts *timestamppb.Timestamp) *uint64
TsToUInt64Ptr returns a timestamppb.Timestamp as a pointer uint64 this is used in place of sql.Null* types
Types ¶
type ItemStorer ¶
type ItemStorer interface { // StoreItem stores the provided [statusthingv1.Item] StoreItem(ctx context.Context, item *v1.Item) (*v1.Item, error) // GetItem gets a [statusthingv1.Item] by its id GetItem(ctx context.Context, itemID string) (*v1.Item, error) // FindItems returns all known [statusthingv1.Item] optionally filtered by the provided [filters.FilterOption] FindItems(ctx context.Context, opts ...filters.FilterOption) ([]*v1.Item, error) // UpdateItem updates the [statusthingv1.Item] by its id with the provided [filters.FilterOption] UpdateItem(ctx context.Context, itemID string, opts ...filters.FilterOption) error // DeleteItem deletes the [statusthingv1.Item] by its id DeleteItem(ctx context.Context, itemID string) error }
ItemStorer storers [statusthingv1.Item]
type NoteStorer ¶
type NoteStorer interface { // StoreNote stores the provided [statusthingv1.Note] associated with the provided [statusthingv1.StatusThing] by its id StoreNote(ctx context.Context, note *v1.Note, statusThingID string) (*v1.Note, error) // GetNote gets a [statusthingv1.Note] by its id GetNote(ctx context.Context, noteID string) (*v1.Note, error) // FindNotes gets all known [statusthingv1.Note] for the provided item id FindNotes(ctx context.Context, itemID string, opts ...filters.FilterOption) ([]*v1.Note, error) // UpdateNote updates the [statusthingv1.Note] with the provided [filters.FilterOption] UpdateNote(ctx context.Context, noteID string, opts ...filters.FilterOption) error // DeleteNote deletes a [statusthingv1.Note] by its id DeleteNote(ctx context.Context, noteID string) error }
NoteStorer stores [statusthingv1.Note]
type StatusStorer ¶
type StatusStorer interface { // StoreStatus stores the provided [statusthingv1.Status] StoreStatus(ctx context.Context, status *v1.Status) (*v1.Status, error) // GetStatus gets a [statusthingv1.Status] by its unique id GetStatus(ctx context.Context, statusID string) (*v1.Status, error) // FindStatus returns all know [statusthingv1.Status] optionally filtered by the provided [filters.FilterOption] FindStatus(ctx context.Context, opts ...filters.FilterOption) ([]*v1.Status, error) // UpdateStatus updates the [statusthingv1.Status] by id with the provided [filters.FilterOption] UpdateStatus(ctx context.Context, statusID string, opts ...filters.FilterOption) error // DeleteStatus deletes a [statusthingv1.Status] by its id DeleteStatus(ctx context.Context, statusID string) error }
StatusStorer stores [statusthingv1.Status]
type StatusThingStorer ¶
type StatusThingStorer interface { NoteStorer StatusStorer ItemStorer UserStorer }
StatusThingStorer stores [sttypes.StatusThing] This is the only store we work directly with The embedding is to allow more flexible storage options
type UserStorer ¶
type UserStorer interface { // StoreUser stores the provied [v1.User] StoreUser(ctx context.Context, user *v1.User) (*v1.User, error) // GetUser gets a [v1.User] by username GetUser(ctx context.Context, username string) (*v1.User, error) // FindUsers finds users FindUsers(ctx context.Context, opts ...filters.FilterOption) ([]*v1.User, error) // UpdateUser updates a [v1.User] UpdateUser(ctx context.Context, username string, opts ...filters.FilterOption) error // DeleteUser deletes a [v1.User] DeleteUser(ctx context.Context, username string) error }
UserStorer stores v1.User
Directories ¶
Path | Synopsis |
---|---|
Package internal contains internal storer code
|
Package internal contains internal storer code |
Package memdb implements the StatusThingStorer via a sqlite in-memory db
|
Package memdb implements the StatusThingStorer via a sqlite in-memory db |
Package sqlite implements a storer backed by sqlite3
|
Package sqlite implements a storer backed by sqlite3 |
driver
Package driver is a package containing a custom sqlite3 driver that enforces fks
|
Package driver is a package containing a custom sqlite3 driver that enforces fks |
Package unimplemented contains unimplemented implementations of storers
|
Package unimplemented contains unimplemented implementations of storers |