buildr/modules/state/api.go
Peter e60726ef9e
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
feat: implement new and man for plugin modules
- use extracted shared libraries
2023-08-23 22:06:26 +02:00

54 lines
1 KiB
Go

package state
import (
"context"
"time"
"github.com/google/uuid"
"code.icb4dc0.de/buildr/buildr/modules/state/ent"
)
type Metadata struct {
ModifiedAt time.Time
TTL *time.Time
}
type Key interface {
Bytes() []byte
}
type EntryOption interface {
applyToEntry(e *ent.KVEntryCreate)
}
type Store interface {
StoreWriter
StoreReader
}
type StoreWriter interface {
Set(ctx context.Context, key Key, state []byte, opts ...EntryOption) error
}
type StoreReader interface {
Get(ctx context.Context, key Key) (state []byte, meta Metadata, err error)
}
type CacheWriter interface {
Set(ctx context.Context, key Key, state []byte) error
}
type Cache interface {
CacheWriter
StoreReader
}
type Plugins interface {
List(ctx context.Context) ([]Plugin, error)
Remove(ctx context.Context, id uuid.UUID) error
ModulesForPlugin(ctx context.Context, id uuid.UUID) ([]PluginModule, error)
UpsertPlugin(ctx context.Context, plugin Plugin) (pluginID uuid.UUID, err error)
UpsertModules(ctx context.Context, modules []PluginModule) error
}