Documentation
¶
Index ¶
- Constants
- Variables
- func AddrByNodeId(node_id proto.NodeId) (string, error)
- func Call(id, method string, args ...interface{}) error
- func CallMR(id, method string, n_rv int, args ...interface{}) error
- func DateByUUID(id proto.UUID) time.Time
- func Init(c *Config) error
- func NodeIdByAddr(addr string) (proto.NodeId, error)
- func NodeIdByPid(pid proto.ProcessId) proto.NodeId
- func RawCall(ctx context.Context, id, method string, n_rv int, args ...interface{}) error
- func Register(id string, conf ActorConfig, args ...interface{})
- func UUIDAt(t time.Time) proto.UUID
- func UUIDBetween(id proto.UUID, start, end time.Time) bool
- type ActorConfig
- type ActorError
- type CodecFactory
- type Config
- type ContainerExecuterFactory
- type Decoder
- type DumpDecoder
- type DumpEncoder
- type Encoder
- type Executer
- type ExecuterFactory
- type InmemoryExecuterFactory
- type InmemoryFactory
- type JsonCodecFactory
- type JsonDecoder
- type JsonEncoder
- type MsgpackCodecFactory
- type MsgpackDecoder
- type MsgpackEncoder
- type Node
- type Process
- type ProcessId
- type SpawnConfig
- type UUID
Constants ¶
const ( Invalid = iota ActorNotFound ActorNoSuchMethod ActorAlreadyHasProcess ActorProcessGone ActorRuntimeError ActorTimeout ActorGoCtxError ActorInvalidPayload ActorInvalidProcess )
const ( REQUEST = iota //kind, msgid, pid, method, args RESPONSE //kind, msgid, err, args NOTIFY //kind, pid, method, args TXN = 0x4 )
payload
const ( KIND = 0 REQUEST_MSGID = 1 REQUEST_PID = 2 REQUEST_METHOD = 3 REQUEST_ARGS = 4 REQUEST_CTX = 5 REQUEST_RECEIVER = 6 RESPONSE_MSGID = 1 RESPONSE_ERROR = 2 RESPONSE_ARGS = 3 NOTIFY_PID = 1 NOTIFY_METHOD = 2 NOTIFY_ARGS = 3 )
const (
SYSTEM_REQUEST = iota
)
Variables ¶
var ConnCreationOnGoing error = fmt.Errorf("connection creation on going")
error
Functions ¶
func Call ¶
send speocified RPC to given id's actor. should call in some goroutine last argument of args is treated as parameter which receive return value
func Register ¶
func Register(id string, conf ActorConfig, args ...interface{})
spawn setup initialization table of given id. its lazy evaluated. thus, actor object is initialized only when someone does RPC of corresponding id.
Types ¶
type ActorConfig ¶
type ActorConfig struct { SpawnConfig SpawnConfig //object which describe how to create Size int //how many process can join this actor? if == 1, means only 1 process can serve as this actor. //if <= 0, means unlimited processes can serve. Throttle int //only enable when Size != 1. }
SpawnOption represent options for spawn
type ActorError ¶
type ActorError struct { Type uint8 Args []interface{} }
func (*ActorError) Error ¶
func (e *ActorError) Error() string
func (*ActorError) GoneProcessId ¶
func (e *ActorError) GoneProcessId() proto.ProcessId
func (*ActorError) Is ¶
func (e *ActorError) Is(typ int) bool
type CodecFactory ¶
type Config ¶
type Config struct { Listeners []net.Listener MeshServerPort int MeshServerNetwork string MeshServerCodec string MeshServerConnTimeoutSec int MeshServerPingInterval int DatabaseAddress string CertPath string DockerCertPath string HostAddress string DefaultApiVersion string Codecs map[string]CodecFactory }
configuration of actor system
type ContainerExecuterFactory ¶
type ContainerExecuterFactory struct { Config container.Config `json:"config"` HostConfig container.HostConfig `json:"host_config"` }
ContainerExecuterFactory
represents configuration for creating actor by container it is compatible for docker remote API (through docker/engine-api)
func (ContainerExecuterFactory) Create ¶
func (cf ContainerExecuterFactory) Create(pid uint64, args ...interface{}) (Executer, error)
func (ContainerExecuterFactory) Destroy ¶
func (cf ContainerExecuterFactory) Destroy(e Executer)
type DumpDecoder ¶
type DumpDecoder struct {
// contains filtered or unexported fields
}
type ExecuterFactory ¶
type ExecuterFactory interface { Create(uint64, ...interface{}) (Executer, error) Destroy(Executer) }
ExecuterFactory represents object can create Executer object
type InmemoryExecuterFactory ¶
type InmemoryExecuterFactory struct { Constructor interface{} // contains filtered or unexported fields }
InmemoryExecuterFactory
func (InmemoryExecuterFactory) Create ¶
func (im InmemoryExecuterFactory) Create(pid uint64, args ...interface{}) (Executer, error)
func (InmemoryExecuterFactory) Destroy ¶
func (im InmemoryExecuterFactory) Destroy(p Executer)
type InmemoryFactory ¶
type InmemoryFactory struct {
Constructor func(args ...interface{}) (interface{}, error)
}
InmemoryFactory represents factory definition using container as go struct.
type JsonCodecFactory ¶
type JsonCodecFactory struct {
// contains filtered or unexported fields
}
func NewJsonCodecFactory ¶
func NewJsonCodecFactory(cfg func(interface{})) *JsonCodecFactory
func (*JsonCodecFactory) NewDecoder ¶
func (cf *JsonCodecFactory) NewDecoder(c net.Conn) Decoder
func (*JsonCodecFactory) NewEncoder ¶
func (cf *JsonCodecFactory) NewEncoder(c net.Conn) Encoder
type JsonDecoder ¶
implementation of DecoderFactory/EncoderFactory, by json.
type JsonEncoder ¶
func (*JsonEncoder) Flush ¶
func (e *JsonEncoder) Flush() error
type MsgpackCodecFactory ¶
type MsgpackCodecFactory struct {
// contains filtered or unexported fields
}
func NewMsgpackCodecFactory ¶
func NewMsgpackCodecFactory(cfg func(interface{})) *MsgpackCodecFactory
func (*MsgpackCodecFactory) NewDecoder ¶
func (cf *MsgpackCodecFactory) NewDecoder(c net.Conn) Decoder
func (*MsgpackCodecFactory) NewEncoder ¶
func (cf *MsgpackCodecFactory) NewEncoder(c net.Conn) Encoder
type MsgpackDecoder ¶
implementation of DecoderFactory/EncoderFactory, by msgpack.
func (*MsgpackDecoder) Decode ¶
func (e *MsgpackDecoder) Decode(v interface{}) error
type MsgpackEncoder ¶
func (*MsgpackEncoder) Encode ¶
func (e *MsgpackEncoder) Encode(v interface{}) error
func (*MsgpackEncoder) Flush ¶
func (e *MsgpackEncoder) Flush() error
type Process ¶
type Process struct { Id proto.ProcessId Executer Executer //all executer methods called concurrenctly from multiple goroutine. // contains filtered or unexported fields }
represents process (worker of each actor)
type ProcessId ¶
represents process id. it is generated by Node.NewUUID. you can resolve which node has this actor via nodes database of cockroachdb. ofcource, node may be restart and actually no actor exists on it, in that case, this node's seed is greater than timestamp part of processid, so caller node can return error.
type SpawnConfig ¶
type SpawnConfig struct { Factory ExecuterFactory // contains filtered or unexported fields }
represent spawn configuration