resource

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func MakeDefaultDeserializeFunc

func MakeDefaultDeserializeFunc[T any]() func(raw []byte) (T, error)

func MakeDefaultSerializeFunc

func MakeDefaultSerializeFunc[T any]() func(o T) ([]byte, error)

func WithBus

func WithBus[SpecType any](bus pkgBusServer.Interface) pkgOptions.Option[Options[SpecType]]

func WithDefaultNamespace

func WithDefaultNamespace[SpecType any](defaultNamespace string) pkgOptions.Option[Options[SpecType]]

func WithDeserializeFunc

func WithDeserializeFunc[SpecType any](deserializeFunc func([]byte) (*pkgResource.Resource[SpecType], error)) pkgOptions.Option[Options[SpecType]]

func WithExtraWatchFunc

func WithExtraWatchFunc[SpecType any](attr string, f AttrWatchHandleFunc[[]byte]) pkgOptions.Option[Options[SpecType]]

func WithFilteringFuncSet

func WithFilteringFuncSet[SpecType any](attr string, filteringFuncSet pkgCache.FilteringFuncSet[SpecType]) pkgOptions.Option[Options[SpecType]]

func WithNKey added in v0.1.1

func WithNKey[SpecType any](nkey nkeys.KeyPair) pkgOptions.Option[Options[SpecType]]

func WithNamespaced

func WithNamespaced[SpecType any](namespaced bool) pkgOptions.Option[Options[SpecType]]

func WithOrderingFunc

func WithOrderingFunc[SpecType any](name string, orderFunc pkgCache.OrderingFunc[SpecType]) pkgOptions.Option[Options[SpecType]]

func WithResource

func WithResource[SpecType any](resource string) pkgOptions.Option[Options[SpecType]]

func WithSerializeFunc

func WithSerializeFunc[SpecType any](serializeFunc func(o *pkgResource.Resource[SpecType]) ([]byte, error)) pkgOptions.Option[Options[SpecType]]

func WithStorage

func WithStorage[SpecType any](storage storage.Interface) pkgOptions.Option[Options[SpecType]]

Types

type AttrWatchCancelFunc added in v0.1.1

type AttrWatchCancelFunc = func() error

type AttrWatchHandleFunc

type AttrWatchHandleFunc[AttrType any] func(namespace string, key string, attr string, value AttrType, prevValue AttrType, delete bool) error

type AttrWatchHandler added in v0.1.1

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

type Diff

type Diff[T any] struct {
	Current  *pkgResource.Resource[T]
	Previous *pkgResource.Resource[T]
}

type ManagerInterface

type ManagerInterface[SpecType any] interface {
	Start() error
	Stop() error

	Apply(o *pkgResource.Resource[SpecType], replace bool) error
	List(namespace string, filter string, order string, offset uint64, limit uint64) ([]*pkgResource.Resource[SpecType], error)
	Exists(namespace string, key string) (bool, error)
	Get(namespace string, key string) (*pkgResource.Resource[SpecType], error)
	Write(namespace string, attr string, key string, data io.ReadCloser, replace bool) error
	Read(namespace string, attr string, key string) (io.ReadCloser, error)
	Delete(namespace string, key string) error

	AttrSetBytes(namespace string, key string, attr string, value []byte, replace bool) error
	AttrGetBytes(namespace string, key string, attr string) ([]byte, error)
	AttrWatchBytes(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[[]byte]) (AttrWatchCancelFunc, error)

	AttrSetBool(namespace string, key string, attr string, value bool, replace bool) error
	AttrGetBool(namespace string, key string, attr string) (bool, error)
	AttrWatchBool(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[bool]) (AttrWatchCancelFunc, error)

	AttrSetString(namespace string, key string, attr string, value string, replace bool) error
	AttrGetString(namespace string, key string, attr string) (string, error)
	AttrWatchString(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[string]) (AttrWatchCancelFunc, error)

	AttrSetInt(namespace string, key string, attr string, value int, replace bool) error
	AttrGetInt(namespace string, key string, attr string) (int, error)
	AttrWatchInt(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[int]) (AttrWatchCancelFunc, error)

	AttrSetInt8(namespace string, key string, attr string, value int8, replace bool) error
	AttrGetInt8(namespace string, key string, attr string) (int8, error)
	AttrWatchInt8(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[int8]) (AttrWatchCancelFunc, error)

	AttrSetInt16(namespace string, key string, attr string, value int16, replace bool) error
	AttrGetInt16(namespace string, key string, attr string) (int16, error)
	AttrWatchInt16(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[int16]) (AttrWatchCancelFunc, error)

	AttrSetInt32(namespace string, key string, attr string, value int32, replace bool) error
	AttrGetInt32(namespace string, key string, attr string) (int32, error)
	AttrWatchInt32(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[int32]) (AttrWatchCancelFunc, error)

	AttrSetInt64(namespace string, key string, attr string, value int64, replace bool) error
	AttrGetInt64(namespace string, key string, attr string) (int64, error)
	AttrWatchInt64(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[int64]) (AttrWatchCancelFunc, error)

	AttrSetUInt(namespace string, key string, attr string, value uint, replace bool) error
	AttrGetUInt(namespace string, key string, attr string) (uint, error)
	AttrWatchUInt(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[uint]) (AttrWatchCancelFunc, error)

	AttrSetUInt8(namespace string, key string, attr string, value uint8, replace bool) error
	AttrGetUInt8(namespace string, key string, attr string) (uint8, error)
	AttrWatchUInt8(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[uint8]) (AttrWatchCancelFunc, error)

	AttrSetUInt16(namespace string, key string, attr string, value uint16, replace bool) error
	AttrGetUInt16(namespace string, key string, attr string) (uint16, error)
	AttrWatchUInt16(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[uint16]) (AttrWatchCancelFunc, error)

	AttrSetUInt32(namespace string, key string, attr string, value uint32, replace bool) error
	AttrGetUInt32(namespace string, key string, attr string) (uint32, error)
	AttrWatchUInt32(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[uint32]) (AttrWatchCancelFunc, error)

	AttrSetUInt64(namespace string, key string, attr string, value uint64, replace bool) error
	AttrGetUInt64(namespace string, key string, attr string) (uint64, error)
	AttrWatchUInt64(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[uint64]) (AttrWatchCancelFunc, error)

	AttrSetFloat32(namespace string, key string, attr string, value float32, replace bool) error
	AttrGetFloat32(namespace string, key string, attr string) (float32, error)
	AttrWatchFloat32(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[float32]) (AttrWatchCancelFunc, error)

	AttrSetFloat64(namespace string, key string, attr string, value float64, replace bool) error
	AttrGetFloat64(namespace string, key string, attr string) (float64, error)
	AttrWatchFloat64(namespace string, attr string, watchHandleFunc AttrWatchHandleFunc[float64]) (AttrWatchCancelFunc, error)

	GetResource() string
	IsNamespaced() bool
	GetDefaultNamespace() string

	BuildKey(namespace string, key string) string
	ParseKey(s string) (string, string, string)
}

func NewManager

func NewManager[SpecType any](opt ...pkgOptions.Option[Options[SpecType]]) (ManagerInterface[SpecType], error)

type Options added in v0.1.1

type Options[SpecType any] struct {
	// contains filtered or unexported fields
}

Source Files

  • error.go
  • impl.go
  • main.go
  • options.go

Jump to

Keyboard shortcuts

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