plugin

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHookFunc

func CreateHookFunc(p *Plugin, hookInfo pluginHookInfo) hook.Func

CreateHookFunc returns a hook.HookFunc that run the hook registered by a plugin

func CreateLambdaHandler

func CreateLambdaHandler(p *Plugin, l string) router.Handler

CreateLambdaHandler creates a router.Handler for the specified lambda function implemented by the plugin.

func RegisterTransport

func RegisterTransport(name string, transport TransportFactory)

RegisterTransport registers a transport factory by name.

Types

type AuthProvider

type AuthProvider struct {
	Name string
	// contains filtered or unexported fields
}

AuthProvider is implemented by plugin to provider user authentication functionality to Skygear.

func NewAuthProvider

func NewAuthProvider(providerName string, plugin *Plugin) *AuthProvider

NewAuthProvider creates a new AuthProvider.

func (*AuthProvider) Info

func (p *AuthProvider) Info(authData map[string]interface{}) (newAuthData map[string]interface{}, err error)

Info calls the AuthProvider implemented by plugin to request for user information.

func (*AuthProvider) Login

func (p *AuthProvider) Login(authData map[string]interface{}) (principalID string, newAuthData map[string]interface{}, err error)

Login calls the AuthProvider implemented by plugin to request for user login authentication

func (*AuthProvider) Logout

func (p *AuthProvider) Logout(authData map[string]interface{}) (newAuthData map[string]interface{}, err error)

Logout calls the AuthProvider implemented by plugin to request for user logout.

type AuthRequest

type AuthRequest struct {
	ProviderName string
	Action       string
	AuthData     map[string]interface{}
}

AuthRequest is sent by Skygear to plugin which contains data for authentication

type AuthResponse

type AuthResponse struct {
	PrincipalID string                 `json:"principal_id"`
	AuthData    map[string]interface{} `json:"auth_data"`
}

AuthResponse is sent by plugin to Skygear which contains authenticated data

type InitContext

type InitContext struct {
	Router           *router.Router
	HookRegistry     *hook.Registry
	ProviderRegistry *provider.Registry
	Scheduler        *cron.Cron
}

InitContext contains reference to structs that will be initialized by plugin.

type Plugin

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

Plugin represents a collection of handlers, hooks and lambda functions that extends or modifies functionality provided by skygear.

func NewPlugin

func NewPlugin(name string, path string, args []string) Plugin

NewPlugin creates an instance of Plugin by transport and configuration.

func (*Plugin) Init

func (p *Plugin) Init(context *InitContext)

Init instantiates a plugin. This sets up hooks and handlers.

type Transport

type Transport interface {
	RunInit() ([]byte, error)
	RunLambda(name string, in []byte) ([]byte, error)
	RunHandler(name string, in []byte) ([]byte, error)

	// RunHook runs the hook specified by recordType and trigger, passing in
	// record as a parameter. Transport may not modify the record passed in.
	//
	// A skydb.Record is returned as a result of invocation. Such record must be
	// a newly allocated instance, and may not share any reference type values
	// in any of its memebers with the record being passed in.
	RunHook(recordType string, trigger string, record *skydb.Record, oldRecord *skydb.Record) (*skydb.Record, error)
	RunTimer(name string, n []byte) ([]byte, error)

	// RunProvider runs the auth provider with the specified AuthRequest.
	RunProvider(request *AuthRequest) (*AuthResponse, error)
}

A Transport represents the interface of data transfer between skygear and remote process.

type TransportFactory

type TransportFactory interface {
	Open(path string, args []string) Transport
}

A TransportFactory is a generic interface to instantiates different kinds of Plugin Transport.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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