Documentation ¶
Index ¶
- Variables
- type ActionError
- type Actions
- type Arg
- type Event
- type Kind
- type Op
- type Registry
- func (r *Registry) Create(ctx context.Context, kind Kind, args ...Arg) (Arg, error)
- func (r *Registry) Delete(ctx context.Context, kind Kind, args ...Arg) (Arg, error)
- func (r *Registry) Do(ctx context.Context, kind Kind, op Op, args ...Arg) (Arg, error)
- func (r *Registry) Get(kind Kind) (Actions, error)
- func (r *Registry) MustRegister(kind Kind, a Actions)
- func (r *Registry) Register(kind Kind, a Actions) error
- func (r *Registry) Update(ctx context.Context, kind Kind, args ...Arg) (Arg, error)
Constants ¶
This section is empty.
Variables ¶
var ( // Create is a constant representing create operations. Create = Op{"Create"} // Update is a constant representing update operations. Update = Op{"Update"} // Delete is a constant representing delete operations. Delete = Op{"Delete"} )
Functions ¶
This section is empty.
Types ¶
type ActionError ¶ added in v1.3.2
type ActionError struct { OperationType Op `json:"operation"` Kind Kind `json:"kind"` Name string `json:"name"` Err error `json:"error"` }
ActionError represents an error happens in performing CRUD action of an entity.
func (*ActionError) Error ¶ added in v1.3.2
func (e *ActionError) Error() string
type Actions ¶
type Actions interface { Create(context.Context, ...Arg) (Arg, error) Delete(context.Context, ...Arg) (Arg, error) Update(context.Context, ...Arg) (Arg, error) }
Actions is an interface for CRUD operations on any entity
type Event ¶
Event represents an event to perform an imperative operation that gets Kong closer to the target state.
func EventFromArg ¶
EventFromArg converts arg into Event. It panics if the type of arg is not Event.
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op represents the type of the operation.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry can hold Kinds and their respective CRUD operations.
func (*Registry) Create ¶
Create calls the registered create action of kind with args and returns the result and error (if any).
func (*Registry) Delete ¶
Delete calls the registered delete action of kind with args and returns the result and error (if any).
func (*Registry) Get ¶
Get returns actions associated with kind. An error will be returned if kind was never registered.
func (*Registry) MustRegister ¶
MustRegister is same as Register but panics on error.