Documentation
¶
Index ¶
- Variables
- func FromContext[T Resource](rc *Context, identifier Identifier) (T, error)
- func FromState[T Resource](state *State, identifier Identifier) (T, error)
- func Provide(i *do.Injector)
- func ProvideRegistry(i *do.Injector)
- func RegisterResourceType[T Resource](registry *Registry, t Type)
- func ToResource[T Resource](data *ResourceData) (T, error)
- func TypedFromRegistry[T Resource](registry *Registry, data *ResourceData) (T, error)
- type Context
- type Event
- type EventType
- type Executor
- type ExecutorType
- type Identifier
- type Plan
- type PlanOptions
- type Registry
- type Resource
- type ResourceData
- type Service
- type State
- func (s *State) Add(data ...*ResourceData)
- func (s *State) AddResource(resources ...Resource) error
- func (s *State) Apply(event *Event) error
- func (s *State) Clone() *State
- func (s *State) CreationOrdered(ignoreMissingDeps bool) (iter.Seq[[]*ResourceData], error)
- func (s *State) DeletionOrdered(ignoreMissingDeps bool) (iter.Seq[[]*ResourceData], error)
- func (s *State) Get(identifier Identifier) (*ResourceData, bool)
- func (s *State) GetAll(resourceType Type) []*ResourceData
- func (s *State) HasResources(identifiers ...Identifier) bool
- func (s *State) Merge(other *State)
- func (s *State) Plan(options PlanOptions, desired *State) (Plan, error)
- func (s *State) PlanAll(options PlanOptions, new ...*State) ([]Plan, error)
- func (s *State) PlanRefresh() (Plan, error)
- func (s *State) Remove(data *ResourceData)
- func (s *State) RemoveByIdentifier(identifier Identifier)
- type Store
- func (s *Store) DeleteByKey(databaseID string) storage.DeleteOp
- func (s *Store) ExistsByKey(databaseID string) storage.ExistsOp
- func (s *Store) GetByKey(databaseID string) storage.GetOp[*StoredState]
- func (s *Store) Key(databaseID string) string
- func (s *Store) Prefix() string
- func (s *Store) Put(item *StoredState) storage.PutOp[*StoredState]
- type StoredState
- type Type
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("resource not found")
var ErrStateNotFound = errors.New("state not found")
Functions ¶
func FromContext ¶
func FromContext[T Resource](rc *Context, identifier Identifier) (T, error)
func ProvideRegistry ¶
func RegisterResourceType ¶
func ToResource ¶
func ToResource[T Resource](data *ResourceData) (T, error)
func TypedFromRegistry ¶
func TypedFromRegistry[T Resource](registry *Registry, data *ResourceData) (T, error)
Types ¶
type Event ¶
type Event struct {
Type EventType `json:"type"`
Resource *ResourceData `json:"resource"`
}
type Executor ¶
type Executor struct {
Type ExecutorType `json:"type"`
ID string `json:"id"`
}
Executor identifies where a resource's lifecycle methods should be executed.
func AnyExecutor ¶
func AnyExecutor() Executor
AnyExecutor will execute resource methods on any host.
func HostExecutor ¶
HostExecutor will execute resource methods on the given host.
func ManagerExecutor ¶
func ManagerExecutor() Executor
ManagerExecutor will execute resource methods on any host with cohort manager capabilities.
func PrimaryExecutor ¶
PrimaryExecutor will execute resource methods on the host that's running the primary instance for the given node.
type ExecutorType ¶
type ExecutorType string
const ( ExecutorTypeHost ExecutorType = "host" ExecutorTypePrimary ExecutorType = "primary" ExecutorTypeAny ExecutorType = "any" ExecutorTypeManager ExecutorType = "manager" )
func (ExecutorType) String ¶
func (e ExecutorType) String() string
type Identifier ¶
func (Identifier) String ¶
func (r Identifier) String() string
type PlanOptions ¶
type PlanOptions struct {
ForceUpdate bool
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
type Resource ¶
type Resource interface {
Executor() Executor
Identifier() Identifier
Dependencies() []Identifier
Refresh(ctx context.Context, rc *Context) error
Create(ctx context.Context, rc *Context) error
Update(ctx context.Context, rc *Context) error
Delete(ctx context.Context, rc *Context) error
DiffIgnore() []string
ResourceVersion() string
}
type ResourceData ¶
type ResourceData struct {
NeedsRecreate bool `json:"needs_recreate"`
Executor Executor `json:"executor"`
Identifier Identifier `json:"identifier"`
Attributes json.RawMessage `json:"attributes"`
Dependencies []Identifier `json:"dependencies"`
DiffIgnore []string `json:"diff_ignore"`
ResourceVersion string `json:"resource_version"`
}
func ToResourceData ¶
func ToResourceData(resource Resource) (*ResourceData, error)
func (*ResourceData) Clone ¶
func (r *ResourceData) Clone() *ResourceData
func (*ResourceData) Differs ¶
func (r *ResourceData) Differs(other *ResourceData) (bool, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) DeleteState ¶
type State ¶
type State struct {
Resources map[Type]map[string]*ResourceData `json:"resources"`
}
func (*State) Add ¶
func (s *State) Add(data ...*ResourceData)
func (*State) AddResource ¶
func (*State) CreationOrdered ¶
CreationOrdered returns a sequence of resources in the order they should be created. In this order dependencies are returned before dependents.
func (*State) DeletionOrdered ¶
DeletionOrdered returns a sequence of resources in the order they should be deleted. In this order dependents are returned before dependencies.
func (*State) Get ¶
func (s *State) Get(identifier Identifier) (*ResourceData, bool)
func (*State) GetAll ¶
func (s *State) GetAll(resourceType Type) []*ResourceData
func (*State) HasResources ¶
func (s *State) HasResources(identifiers ...Identifier) bool
func (*State) PlanRefresh ¶
func (*State) Remove ¶
func (s *State) Remove(data *ResourceData)
func (*State) RemoveByIdentifier ¶
func (s *State) RemoveByIdentifier(identifier Identifier)
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Put ¶
func (s *Store) Put(item *StoredState) storage.PutOp[*StoredState]
type StoredState ¶
type StoredState struct {
storage.StoredValue
DatabaseID string `json:"database_id"`
State *State `json:"state"`
}