isolator

package module
v0.0.0-...-71aab76 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

README

isolator

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultObjectBuilder = NewClassicObjectBuilder()
)

Functions

func RegisterObjects

func RegisterObjects(objects ...Object) (err error)

Types

type ClassicObjectBuilder

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

func (*ClassicObjectBuilder) DeriveObjects

func (p *ClassicObjectBuilder) DeriveObjects(session *Session, types ...reflect.Type) (objects []Object, err error)

func (*ClassicObjectBuilder) RegisterObjects

func (p *ClassicObjectBuilder) RegisterObjects(objects ...Object) (err error)

type Isolator

type Isolator struct {
	ObjectBuilder ObjectBuilder
	// contains filtered or unexported fields
}

func NewIsolator

func NewIsolator(opts ...IsolatorOption) *Isolator

Invoke is a func for reflect Call logic func

fn:= func(arg1, arg2, arg3 string) (interface{}, error) {
		if(arg1!="xxxx") {
			return nil, error.New("arg1 error")
		}
		return func(obj1 Repo1, obj2 Repo2) (result string, err error) {
			......
			return "good"
		}, nil
}

Repo1, Repo2 is build by object builder

func (*Isolator) Invoke

func (p *Isolator) Invoke(fn interface{}, args ...interface{}) (ret Result)

func (*Isolator) InvokeWithSession

func (p *Isolator) InvokeWithSession(session *Session, fn interface{}, args ...interface{}) (ret Result)

func (*Isolator) ObjectSessionOptions

func (p *Isolator) ObjectSessionOptions(obj Object, opts ...SessionOption)

func (*Isolator) ObjectsSessionOptions

func (p *Isolator) ObjectsSessionOptions(objs []Object, opts ...SessionOption)

func (*Isolator) Options

func (p *Isolator) Options(opts ...IsolatorOption)

type IsolatorOption

type IsolatorOption func(*Isolator)

func IsolatorObjectBuilder

func IsolatorObjectBuilder(builder ObjectBuilder) IsolatorOption

type Object

type Object interface {
	Derive(session *Session) (obj Object, err error)
}

type ObjectBuilder

type ObjectBuilder interface {
	RegisterObjects(objects ...Object) (err error)
	DeriveObjects(session *Session, types ...reflect.Type) (objects []Object, err error)
}

func NewClassicObjectBuilder

func NewClassicObjectBuilder() ObjectBuilder

type Result

type Result []reflect.Value

func (Result) End

func (p Result) End(fn interface{}) error

type Session

type Session struct {
	ID         string
	Context    context.Context
	CreateTime int64
	OnError    SessionOnErrorFunc
	OnSuccess  SessionOnSuccessFunc
}

func NewSession

func NewSession(opts ...SessionOption) *Session

func (*Session) Options

func (p *Session) Options(opts ...SessionOption)

type SessionOnErrorFunc

type SessionOnErrorFunc func(*Session, error)

type SessionOnSuccessFunc

type SessionOnSuccessFunc func(*Session)

type SessionOption

type SessionOption func(*Session)

func SessionOnError

func SessionOnError(fn SessionOnErrorFunc) SessionOption

func SessionOnSuccess

func SessionOnSuccess(fn SessionOnSuccessFunc) SessionOption

type Sessions

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

func NewSessions

func NewSessions() *Sessions

func (*Sessions) New

func (p *Sessions) New(types ...reflect.Type) (session *Session)

func (*Sessions) RegisterObjectOptions

func (p *Sessions) RegisterObjectOptions(obj Object, opts ...SessionOption)

Directories

Path Synopsis
example
extension

Jump to

Keyboard shortcuts

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