resource

package
v0.0.0-...-198801e Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Destroyed   state.Enum = 1
	Reconciling state.Enum = 100
	Destroying  state.Enum = 101
	Synced      state.Enum = 200
	OutOfSync   state.Enum = 300
)

Variables

View Source
var ErrNotExist = errors.New("resource does not exist")

Functions

func ListNodes

func ListNodes[T any](com manifold.Node, lister Lister[T]) (nodes node.Nodes)

for use in components implementing Nodes()

func NewNode

func NewNode[C, R, L any](name string, parent manifold.Node, oldView string, creator Creater[C, R]) manifold.Node

func ReadFromList

func ReadFromList[R any](ctx context.Context, lister Lister[R], id ID) (*R, error)

Types

type Creater

type Creater[C any, R any] interface {
	Create(context.Context, *C) (Resource[R], error)
}

type Deleter

type Deleter interface {
	Delete(context.Context, ID) error
}

type EventHandler

type EventHandler interface {
	HandleEvent(name string, data any)
}

type ID

type ID string

type Lister

type Lister[R any] interface {
	List(context.Context) ([]Resource[R], error)
}

type NewResource

type NewResource[C any] struct {
	Draft  *C
	Save   func()
	Cancel func()
}

type Provider

type Provider[T any] interface {
	// CurrentState() state.Enum
	Client() *T
}

type ReadDeleter

type ReadDeleter[R any] interface {
	Reader[R]
	Deleter
}

type Reader

type Reader[R any] interface {
	Read(context.Context, ID) (R, error)
}

type Resource

type Resource[R any] struct {
	ID     ID
	Status string

	Latest   R
	LastRead time.Time
	// contains filtered or unexported fields
}

func New

func New[R any](res Reader[*R], id string, v R) Resource[R]

func (*Resource[R]) CheckSync

func (r *Resource[R]) CheckSync()

func (*Resource[R]) Delete

func (r *Resource[R]) Delete(n *node.Raw) bool

func (*Resource[R]) SetSync

func (r *Resource[R]) SetSync(v *R)

Jump to

Keyboard shortcuts

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