hook

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BeforeSave   Kind = "beforeSave"
	AfterSave         = "afterSave"
	BeforeDelete      = "beforeDelete"
	AfterDelete       = "afterDelete"
)

The four kind of hooks provided by Skygear.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

Func defines the interface of a function that can be hooked.

The supplied record is fully fetched for all four kind of hooks.

type Kind

type Kind string

Kind defines when a hook should be executed on mutation of skydb.Record.

type Registry

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

Registry is a registry of hooks by record type.

It provides method to execute hooks but is not responsible to execute registered hook. The responsibility is currently handled by handler.

In future the registry should hook itself into Record lifecycle and manage hooks executions itself. Such hooking point does not exist at the moment.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns a Registry ready for use.

func (*Registry) ExecuteHooks

func (r *Registry) ExecuteHooks(ctx context.Context, kind Kind, record *skydb.Record, oldRecord *skydb.Record) skyerr.Error

ExecuteHooks executes registered hooks for the type of supplied record to be executed at the specific kind of moment.

If one of the hooks returns an error, it halts execution of other hooks and return sthat error untouched.

func (*Registry) Register

func (r *Registry) Register(kind Kind, recordType string, hook Func) error

Register adds the specific hook for the supplied recordType to be executed at the moment provided by kind.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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