hook

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2018 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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