hook

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

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.

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

The four kind of hooks provided by Skygear.

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