Documentation ¶
Index ¶
- Variables
- type BasicAPIHandler
- func (h *BasicAPIHandler) AsyncWatch(f WatcherCallback) StoppableWatcher
- func (h *BasicAPIHandler) Create(resource Resource, createOpts *CreateOptions) error
- func (h *BasicAPIHandler) Decorate(resource Resource)
- func (h *BasicAPIHandler) Delete(id string) error
- func (h *BasicAPIHandler) Get(id string) (Resource, bool)
- func (h *BasicAPIHandler) Index() map[string]Resource
- func (h *BasicAPIHandler) Name() string
- func (h *BasicAPIHandler) New() Resource
- func (h *BasicAPIHandler) Unmarshal(b []byte) (resource Resource, err error)
- func (h *BasicAPIHandler) Update(id string, resource Resource) (Resource, bool, error)
- type BasicResource
- type BasicStoppableWatcher
- type CreateOptions
- type Handler
- type Resource
- type ResourceHandler
- type ResourceWatcher
- type StoppableWatcher
- type WatchableHandler
- type WatcherCallback
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicatedResource = errors.New("duplicated resource")
ErrDuplicatedResource is returned when a resource is duplicated
var ErrNotFound = errors.New("resource not found")
ErrNotFound is returned when a resource could not be found
var ErrNotUpdatable = errors.New("resource not updatable")
ErrNotUpdatable is returned when an resource could not be modified
Functions ¶
This section is empty.
Types ¶
type BasicAPIHandler ¶
type BasicAPIHandler struct { ResourceHandler ResourceHandler EtcdClient *etcdclient.Client }
BasicAPIHandler basic implementation of an Handler, should be used as embedded struct for the most part of the resource
func (*BasicAPIHandler) AsyncWatch ¶
func (h *BasicAPIHandler) AsyncWatch(f WatcherCallback) StoppableWatcher
AsyncWatch registers a new resource watcher
func (*BasicAPIHandler) Create ¶
func (h *BasicAPIHandler) Create(resource Resource, createOpts *CreateOptions) error
Create a new resource in Etcd
func (*BasicAPIHandler) Decorate ¶
func (h *BasicAPIHandler) Decorate(resource Resource)
Decorate the resource
func (*BasicAPIHandler) Delete ¶
func (h *BasicAPIHandler) Delete(id string) error
Delete a resource
func (*BasicAPIHandler) Get ¶
func (h *BasicAPIHandler) Get(id string) (Resource, bool)
Get a specific resource
func (*BasicAPIHandler) Index ¶
func (h *BasicAPIHandler) Index() map[string]Resource
Index returns the list of resource available in Etcd
func (*BasicAPIHandler) Name ¶
func (h *BasicAPIHandler) Name() string
Name returns the resource name
type BasicResource ¶
type BasicResource struct {
UUID string `yaml:"UUID"`
}
BasicResource is a resource with a unique identifier easyjson:json swagger:ignore
func (*BasicResource) GetName ¶
func (b *BasicResource) GetName() string
GetName returns the resource name
func (*BasicResource) Validate ¶
func (b *BasicResource) Validate() error
Validate integrity of the resource
type BasicStoppableWatcher ¶
type BasicStoppableWatcher struct { StoppableWatcher // contains filtered or unexported fields }
BasicStoppableWatcher basic implementation of a resource watcher
func (*BasicStoppableWatcher) Stop ¶
func (s *BasicStoppableWatcher) Stop()
Stop the resource watcher
type CreateOptions ¶
CreateOptions describes the available options when creating a resource
type Handler ¶
type Handler interface { Name() string New() Resource Index() map[string]Resource Get(id string) (Resource, bool) Decorate(resource Resource) Create(resource Resource, createOpts *CreateOptions) error Delete(id string) error Update(id string, resource Resource) (Resource, bool, error) }
Handler describes resources for each API
type ResourceHandler ¶
ResourceHandler aims to creates new resource of an API
type ResourceWatcher ¶
type ResourceWatcher interface {
AsyncWatch(f WatcherCallback) StoppableWatcher
}
ResourceWatcher asynchronous interface
type WatchableHandler ¶
type WatchableHandler interface { Handler ResourceWatcher }
WatchableHandler describes a handler that can watched for updates
type WatcherCallback ¶
WatcherCallback callback called by the resource watcher