qtiny

package
v0.0.0-...-edd91d0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	NanoEventStop = 0x0010
)

Variables

View Source
var MessageTraceDepthDefault = 3

Functions

This section is empty.

Types

type Discovery

type Discovery interface {
	GetNodeId() string
	SetNodeId(string)

	GetLogger() *log.Logger
	SetLogger(logger *log.Logger)

	Start(config map[string]interface{}) error
	Stop(config map[string]interface{}) error

	NanoRemoteRegister(nano *Nano) error
	NanoRemoteUnregister(nano *Nano) error
	NanoRemoteGet(address string) (*Nano, error)

	NanoLocalRegister(nano *Nano) error
	NanoLocalUnregister(nano *Nano) error
	NanoLocalGet(address string) (*Nano, error)

	GatewayGet(gatekey string) Gateway
	GatewayPublish(gatekey string, gateway Gateway) error
	GatewayUnpublish(gatekey string) error

	PortalGet(address string) PortalKind
}

type Future

type Future struct {
	util.LazyData

	Name string
	// contains filtered or unexported fields
}

func (*Future) Code

func (o *Future) Code() int

func (*Future) Err

func (o *Future) Err() error

func (*Future) ErrCause

func (o *Future) ErrCause() interface{}

func (*Future) Fail

func (o *Future) Fail(code int, errCause interface{})

func (*Future) GetContext

func (o *Future) GetContext() interface{}

func (*Future) IsFail

func (o *Future) IsFail() bool

func (*Future) IsSucceed

func (o *Future) IsSucceed() bool

func (*Future) OnFail

func (o *Future) OnFail(callback FutureCallback) *Future

func (*Future) OnFinally

func (o *Future) OnFinally(callback FutureCallback) *Future

func (*Future) OnSucceed

func (o *Future) OnSucceed(callback FutureCallback) *Future

func (*Future) Result

func (o *Future) Result() interface{}

func (*Future) Run

func (o *Future) Run() *Future

func (*Future) RunAndWait

func (o *Future) RunAndWait(timeout time.Duration) (*Future, error)

func (*Future) SetContext

func (o *Future) SetContext(context interface{}) *Future

func (*Future) SetRoutine

func (o *Future) SetRoutine(routine FutureCallback) *Future

func (*Future) Succeed

func (o *Future) Succeed(code int, result interface{})

func (*Future) Then

func (o *Future) Then(callback FutureCallback) *Future

func (*Future) TryFail

func (o *Future) TryFail(code int, cause interface{})

func (*Future) TrySucceed

func (o *Future) TrySucceed(code int, result interface{})

type FutureCallback

type FutureCallback func(event FutureEvent, future *Future) FutureCallbackReturn

type FutureCallbackReturn

type FutureCallbackReturn int
const (
	FutureCallbackContinue  FutureCallbackReturn = 0x0000
	FutureCallbackTerminate FutureCallbackReturn = 0x0001
)

type FutureEvent

type FutureEvent int
const (
	FutureEventRoutine FutureEvent = 0x0001
	FutureEventThen    FutureEvent = 0x0010
	FutureEventSucceed FutureEvent = 0x1000
	FutureEventFail    FutureEvent = 0x2000
	FutureEventFinally FutureEvent = 0x4000
)

type Gateway

type Gateway interface {
	GetId() string
	SetId(string)
	GetIdHash() uint32

	GetNodeId() string
	SetNodeId(string)
	GetNodeIdHash() uint32

	GetType() string
	GetTypeHash() uint32

	GetMeta() map[string]interface{}

	GetConfig() map[string]interface{}
	SetConfig(map[string]interface{})

	GetLogger() *log.Logger
	SetLogger(logger *log.Logger)

	Start(config map[string]interface{}) error
	Stop(config map[string]interface{}) error

	Poll(limit int) (chan *Message, error)

	Post(message *Message, discovery Discovery) error
	Multicast(message *Message, discovery Discovery) error
	Broadcast(message *Message, discovery Discovery) error

	EventChannelGet(channelId string) (<-chan *GatewayEventBox, error)
	EventChannelClose(channelId string) error
}

type GatewayEvent

type GatewayEvent int
const (
	GatewayEventConnected    GatewayEvent = 1
	GatewayEventDisconnected GatewayEvent = 2
	GatewayEventConfigChange GatewayEvent = 3
)

type GatewayEventBox

type GatewayEventBox struct {
	Event  GatewayEvent
	Source Gateway
	Meta   interface{}
}

type LifeCycler

type LifeCycler interface {
	Start(config map[string]interface{}, future Future) error
	Stop(config map[string]interface{}, future Future) error
}

type Message

type Message struct {
	Type MessageType

	LocalFlag MessageFlag
	ShareFlag MessageFlag

	Address string
	Gatekey string

	Data     interface{}
	Timeout  time.Duration
	Canceled bool

	Err error

	Sender   string
	Receiver string

	Session        string
	SessionRelated interface{}

	Headers MessageHeaders
	Options MessageOptions

	Replier    string
	ReplyId    uint64
	ReplyErr   string
	ReplyTrace string
	TraceDepth int

	ReplyCode    int
	ReplyData    interface{}
	ReplyChannel chan *Message

	Handler MessageHandler

	Related *Message
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(address string, data interface{}, timeout time.Duration) (message *Message)

func (*Message) Clone

func (o *Message) Clone() *Message

func (*Message) Error

func (o *Message) Error(code int, errmsg string, args ...interface{}) error

func (*Message) FromJson

func (o *Message) FromJson(data []byte) error

func (*Message) FromMap

func (o *Message) FromMap(m map[string]interface{})

func (*Message) GetTraceDepth

func (o *Message) GetTraceDepth() int

func (*Message) IsError

func (o *Message) IsError() bool

func (*Message) Overseer

func (o *Message) Overseer() *Microroller

func (*Message) Reply

func (o *Message) Reply(code int, data interface{}) error

func (*Message) SetHandler

func (o *Message) SetHandler(handler MessageHandler) *Message

func (*Message) SetHeaders

func (o *Message) SetHeaders(headers MessageHeaders) *Message

func (*Message) SetOptions

func (o *Message) SetOptions(options MessageOptions) *Message

func (*Message) SetTimeout

func (o *Message) SetTimeout(timeout time.Duration) *Message

func (*Message) String

func (o *Message) String() string

func (*Message) ToJson

func (o *Message) ToJson() ([]byte, error)

func (*Message) ToJsonString

func (o *Message) ToJsonString() (string, error)

func (*Message) ToMap

func (o *Message) ToMap() map[string]interface{}

func (*Message) TypeString

func (o *Message) TypeString() string

func (*Message) WaitReply

func (o *Message) WaitReply(timeout time.Duration) (*Message, bool)

type MessageFlag

type MessageFlag uint32
const (
	MessageFlagLocalOnly  MessageFlag = 0x0001
	MessageFlagRemoteOnly MessageFlag = 0x0002
)

type MessageHandler

type MessageHandler func(message *Message)

type MessageHeaders

type MessageHeaders map[string]interface{}

type MessageOptions

type MessageOptions map[string]interface{}

type MessageType

type MessageType uint32
const (
	MessageTypeSend      MessageType = 0x0001
	MessageTypeReply     MessageType = 0x0002
	MessageTypeFail      MessageType = 0x0004
	MessageTypeBroadcast MessageType = 0x1000
	MessageTypeMulticast MessageType = 0x2000
)

type Microroller

type Microroller struct {
	ErrHandler OverseerErrorHandler

	Verbose int
	// contains filtered or unexported fields
}

func (*Microroller) Broadcast

func (o *Microroller) Broadcast(gatekey string, message *Message) error

func (*Microroller) GetDiscovery

func (o *Microroller) GetDiscovery() Discovery

func (*Microroller) GetLogger

func (o *Microroller) GetLogger() *log.Logger

func (*Microroller) GetTina

func (o *Microroller) GetTina() *Tina

func (*Microroller) Multicast

func (o *Microroller) Multicast(gatekey string, message *Message) error

func (*Microroller) NanoLocalRegister

func (o *Microroller) NanoLocalRegister(nano *Nano) error

func (*Microroller) NanoLocalUnregister

func (o *Microroller) NanoLocalUnregister(nano *Nano) error

func (*Microroller) Post

func (o *Microroller) Post(gatekey string, request *Message) (response *Message, err error)

func (*Microroller) SetDiscovery

func (o *Microroller) SetDiscovery(discovery Discovery)

func (*Microroller) SetGateways

func (o *Microroller) SetGateways(gateways map[string]Gateway, gatewaydef string) *Microroller

func (*Microroller) SetLogger

func (o *Microroller) SetLogger(logger *log.Logger) *Microroller

func (*Microroller) Start

func (o *Microroller) Start(config map[string]interface{}) error

func (*Microroller) Stop

func (o *Microroller) Stop() error

type Nano

type Nano struct {
	Id string

	Address string
	Options NanoOptions
	Handler NanoHandler

	Flag NanoFlag
	// contains filtered or unexported fields
}

func CloneNano

func CloneNano(nano *Nano) *Nano

func NewNano

func NewNano(address string, flag NanoFlag, options NanoOptions, handler NanoHandler) *Nano

func (*Nano) CallbackAdd

func (o *Nano) CallbackAdd(callback NanoCallback) *Nano

func (*Nano) CallbackInvoke

func (o *Nano) CallbackInvoke(event NanoEvent, context interface{}, dopanic bool) (err error)

func (*Nano) Dispatch

func (o *Nano) Dispatch(message *Message)

func (*Nano) GatewayGetData

func (o *Nano) GatewayGetData(address string) interface{}

func (*Nano) LocalAdd

func (o *Nano) LocalAdd(silbing *Nano)

func (*Nano) LocalIterate

func (o *Nano) LocalIterate(routine func(*Nano) (bool, error)) error

func (*Nano) LocalRemove

func (o *Nano) LocalRemove(id string) error

func (*Nano) PortalAdd

func (o *Nano) PortalAdd(address string, data interface{})

func (*Nano) PortalAddress

func (o *Nano) PortalAddress(index int32) string

func (*Nano) PortalAddresses

func (o *Nano) PortalAddresses() []string

func (*Nano) PortalCount

func (o *Nano) PortalCount() int

func (*Nano) PortalPointer

func (o *Nano) PortalPointer() ([]string, int)

func (*Nano) PortalRemove

func (o *Nano) PortalRemove(address string)

func (*Nano) PortalSet

func (o *Nano) PortalSet(address []string, data []interface{})

type NanoCallback

type NanoCallback func(event NanoEvent, nano *Nano, context interface{})

type NanoEvent

type NanoEvent int

type NanoFlag

type NanoFlag int
const (
	NanoFlagLocalOnly NanoFlag = 1
)

type NanoHandler

type NanoHandler func(message *Message)

type NanoOptions

type NanoOptions map[string]interface{}

type OverseerErrorHandler

type OverseerErrorHandler func(event string, err interface{}, microroller *Microroller)

type Portal

type Portal struct {
	Type       string
	TypeHash   uint32
	Path       string
	Address    string
	Discoverer Discovery
	Meta       map[string]interface{}
}

func (*Portal) GetAddress

func (o *Portal) GetAddress() string

func (*Portal) GetMeta

func (o *Portal) GetMeta() map[string]interface{}

func (*Portal) GetType

func (o *Portal) GetType() string

func (*Portal) GetTypeHash

func (o *Portal) GetTypeHash() uint32

func (*Portal) SetMeta

func (o *Portal) SetMeta(meta map[string]interface{})

type PortalKind

type PortalKind interface {
	GetType() string
	GetTypeHash() uint32
	GetAddress() string
	GetMeta() map[string]interface{}
}

type Tina

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

func GetTina

func GetTina() *Tina

func (*Tina) Deploy

func (o *Tina) Deploy(id string, guide TinyGuideKind, config map[string]interface{}, flag TinyFlag, options TinyOptions) *Future

func (*Tina) GetDiscovery

func (o *Tina) GetDiscovery() Discovery

func (*Tina) GetGateways

func (o *Tina) GetGateways() map[string]Gateway

func (*Tina) GetLogger

func (o *Tina) GetLogger() *log.Logger

func (*Tina) GetMicroroller

func (o *Tina) GetMicroroller() *Microroller

func (*Tina) GetNodeId

func (o *Tina) GetNodeId() string

func (*Tina) SetDiscovery

func (o *Tina) SetDiscovery(discovery Discovery)

func (*Tina) SetGateways

func (o *Tina) SetGateways(gateways map[string]Gateway, gatewaydef string) *Tina

func (*Tina) SetLogger

func (o *Tina) SetLogger(logger *log.Logger) *Tina

func (*Tina) SetMicroroller

func (o *Tina) SetMicroroller(microroller *Microroller) *Tina

func (*Tina) Start

func (o *Tina) Start(config map[string]interface{}) error

func (*Tina) Stop

func (o *Tina) Stop() error

func (*Tina) Undeploy

func (o *Tina) Undeploy(tinyId string) *Future

type Tiny

type Tiny struct {
	util.LazyData
	// contains filtered or unexported fields
}

func (*Tiny) GetConfig

func (o *Tiny) GetConfig() map[string]interface{}

func (*Tiny) GetGroup

func (o *Tiny) GetGroup() string

func (*Tiny) GetGuide

func (o *Tiny) GetGuide() TinyGuideKind

func (*Tiny) GetId

func (o *Tiny) GetId() string

func (*Tiny) GetOptions

func (o *Tiny) GetOptions() TinyOptions

func (*Tiny) GetTina

func (o *Tiny) GetTina() *Tina

func (*Tiny) NanoLocalRegister

func (o *Tiny) NanoLocalRegister(nano *Nano) error

func (*Tiny) NanoLocalUnregister

func (o *Tiny) NanoLocalUnregister(nano *Nano) error

func (*Tiny) Post

func (o *Tiny) Post(gatekey string, request *Message) (*Message, error)

func (*Tiny) Start

func (o *Tiny) Start(future *Future)

func (*Tiny) Stop

func (o *Tiny) Stop(future *Future)

type TinyFlag

type TinyFlag int
const (
	TinyFlagDeploySync TinyFlag = 0x1000
)

type TinyGuide

type TinyGuide struct {
	util.LazyData

	Start TinyGuideCallback
	Stop  TinyGuideCallback
	Err   TinyGuideCallback
	// contains filtered or unexported fields
}

func (*TinyGuide) CallbackAdd

func (o *TinyGuide) CallbackAdd(callback TinyGuideCallback)

func (*TinyGuide) Invoke

func (o *TinyGuide) Invoke(event TinyGuideEvent, tiny TinyKind, config map[string]interface{}, future *Future)

type TinyGuideCallback

type TinyGuideCallback func(event TinyGuideEvent, tiny TinyKind, guide TinyGuideKind, config map[string]interface{}, future *Future, err error)

type TinyGuideEvent

type TinyGuideEvent int
const (
	TinyGuideEventStart  TinyGuideEvent = 0x0001
	TinyGuideEventStop   TinyGuideEvent = 0x0002
	TinyGuideEventError  TinyGuideEvent = 0x0010
	TinyGuideEventAspect TinyGuideEvent = 0x1000
)

type TinyGuideKind

type TinyGuideKind interface {
	util.LazyDataKind
	CallbackAdd(callback TinyGuideCallback)
	Invoke(event TinyGuideEvent, tiny TinyKind, config map[string]interface{}, future *Future)
}

type TinyKind

type TinyKind interface {
	util.LazyDataKind
	GetId() string
	GetGroup() string
	GetGuide() TinyGuideKind
	GetOptions() TinyOptions
	GetConfig() map[string]interface{}
	GetTina() *Tina
	Post(gatekey string, request *Message) (response *Message, err error)
	NanoLocalRegister(nano *Nano) error
	NanoLocalUnregister(nano *Nano) error
}

type TinyOptions

type TinyOptions map[string]interface{}

Jump to

Keyboard shortcuts

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