Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func New added in v0.5.0

func New(c Config) *lockingStore

func NewMemoryBackend added in v0.5.0

func NewMemoryBackend() *memoryBackend

Types

type Backend added in v0.5.0

type Backend interface {
	GetGateway(ctx context.Context, id core.GatewayID) ([]byte, error)
	ListGateways(ctx context.Context) ([][]byte, error)
	DeleteGateway(ctx context.Context, id core.GatewayID) error
	UpsertGateways(ctx context.Context, gateways ...GatewayRecord) error
	GetRoute(ctx context.Context, id string) ([]byte, error)
	ListRoutes(ctx context.Context) ([][]byte, error)
	DeleteRoute(ctx context.Context, id string) error
	UpsertRoutes(ctx context.Context, routes ...RouteRecord) error
}

Backend is used for persisting and querying gateways and routes

type Binder added in v0.5.0

type Binder interface {
	Bind(ctx context.Context, gateway Gateway, route Route) bool
	Unbind(ctx context.Context, gateway Gateway, route Route) bool
}

type CompareResult

type CompareResult int

type Config added in v0.5.0

type Config struct {
	Adapter       core.SyncAdapter
	Backend       Backend
	Binder        Binder
	Logger        hclog.Logger
	Marshaler     Marshaler
	StatusUpdater StatusUpdater
}

type Gateway

type Gateway interface {
	ID() core.GatewayID
	Resolve() core.ResolvedGateway
	CanFetchSecrets(secrets []string) (bool, error)
}

Gateway describes a gateway.

type GatewayRecord added in v0.5.0

type GatewayRecord struct {
	ID   core.GatewayID
	Data []byte
}

GatewayRecord represents a serialized Gateway

type Marshaler added in v0.5.0

type Marshaler interface {
	UnmarshalRoute(data []byte) (Route, error)
	MarshalRoute(Route) ([]byte, error)
	UnmarshalGateway(data []byte) (Gateway, error)
	MarshalGateway(Gateway) ([]byte, error)
}

type ReadStore added in v0.5.0

type ReadStore interface {
	GetGateway(ctx context.Context, id core.GatewayID) (Gateway, error)
	ListGateways(ctx context.Context) ([]Gateway, error)

	GetRoute(ctx context.Context, id string) (Route, error)
	ListRoutes(ctx context.Context) ([]Route, error)
}

type Route

type Route interface {
	ID() string
}

Route should be implemented by all route source integrations

type RouteRecord added in v0.5.0

type RouteRecord struct {
	ID   string
	Data []byte
}

RouteRecord represents a serialized Route

type StatusUpdater added in v0.5.0

type StatusUpdater interface {
	UpdateGatewayStatusOnSync(ctx context.Context, gateway Gateway, sync func() (bool, error)) error
	UpdateRouteStatus(ctx context.Context, route Route) error
}

type Store

type Store interface {
	ReadStore
	WriteStore
}

Store is used for persisting and querying gateways and routes

type WriteStore added in v0.5.0

type WriteStore interface {
	UpsertGateway(ctx context.Context, gateway Gateway, updateConditionFn func(current Gateway) bool) error
	DeleteGateway(ctx context.Context, id core.GatewayID) error

	UpsertRoute(ctx context.Context, route Route, updateConditionFn func(current Route) bool) error
	DeleteRoute(ctx context.Context, id string) error

	SyncAllAtInterval(ctx context.Context)
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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