factory

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: MIT Imports: 6 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TagName = "factory"
)

Functions

This section is empty.

Types

type Args

type Args interface {
	Instance() interface{}
	Parent() Args
	Context() context.Context
	// contains filtered or unexported methods
}

type Factory

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

func NewFactory

func NewFactory(model interface{}) *Factory

NewFactory returns a new factory for specified model class Each generator is applied in the order in which they are declared

func (*Factory) Attr

func (fa *Factory) Attr(name string, gen func(Args) (interface{}, error)) *Factory

func (*Factory) Construct

func (fa *Factory) Construct(ptr interface{}) error

Bind values of a new objects to a pointer to struct.

ptr: a pointer to struct

func (*Factory) ConstructWithContextAndOption

func (fa *Factory) ConstructWithContextAndOption(ctx context.Context, ptr interface{}, opt map[string]interface{}) error

Bind values of a new objects to a pointer to struct with context and option.

ctx: context object ptr: a pointer to struct opt: attibute values

func (*Factory) ConstructWithOption

func (fa *Factory) ConstructWithOption(ptr interface{}, opt map[string]interface{}) error

Bind values of a new objects to a pointer to struct with option.

ptr: a pointer to struct opt: attibute values

func (*Factory) Create

func (fa *Factory) Create() (interface{}, error)

func (*Factory) CreateWithContext

func (fa *Factory) CreateWithContext(ctx context.Context) (interface{}, error)

func (*Factory) CreateWithContextAndOption

func (fa *Factory) CreateWithContextAndOption(ctx context.Context, opt map[string]interface{}) (interface{}, error)

func (*Factory) CreateWithOption

func (fa *Factory) CreateWithOption(opt map[string]interface{}) (interface{}, error)

func (*Factory) MustCreate

func (fa *Factory) MustCreate() interface{}

func (*Factory) MustCreateWithContextAndOption

func (fa *Factory) MustCreateWithContextAndOption(ctx context.Context, opt map[string]interface{}) interface{}

func (*Factory) MustCreateWithOption

func (fa *Factory) MustCreateWithOption(opt map[string]interface{}) interface{}

func (*Factory) OnCreate

func (fa *Factory) OnCreate(cb func(Args) error) *Factory

OnCreate registers a callback on object creation. If callback function returns error, object creation is failed.

func (*Factory) SeqInt

func (fa *Factory) SeqInt(name string, gen func(int) (interface{}, error)) *Factory

func (*Factory) SeqInt64

func (fa *Factory) SeqInt64(name string, gen func(int64) (interface{}, error)) *Factory

func (*Factory) SeqString

func (fa *Factory) SeqString(name string, gen func(string) (interface{}, error)) *Factory

func (*Factory) SubFactory

func (fa *Factory) SubFactory(name string, sub *Factory) *Factory

func (*Factory) SubRecursiveFactory

func (fa *Factory) SubRecursiveFactory(name string, sub *Factory, getLimit func() int) *Factory

func (*Factory) SubRecursiveSliceFactory

func (fa *Factory) SubRecursiveSliceFactory(name string, sub *Factory, getSize, getLimit func() int) *Factory

func (*Factory) SubSliceFactory

func (fa *Factory) SubSliceFactory(name string, sub *Factory, getSize func() int) *Factory

type Stacks

type Stacks []*int64

func (*Stacks) Has

func (st *Stacks) Has(idx int) bool

func (*Stacks) Next

func (st *Stacks) Next(idx int) bool

func (*Stacks) Pop

func (st *Stacks) Pop(idx, delta int)

func (*Stacks) Push

func (st *Stacks) Push(idx, delta int)

func (*Stacks) Set

func (st *Stacks) Set(idx, val int)

Set method is not goroutine safe.

func (*Stacks) Size

func (st *Stacks) Size(idx int) int64

Jump to

Keyboard shortcuts

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