yue

package module
v0.0.0-...-1407378 Latest Latest
Warning

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

Go to latest
Published: May 24, 2016 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Invalid = iota
	ActorNotFound
	ActorNoSuchMethod
	ActorAlreadyHasProcess
	ActorProcessGone
	ActorRuntimeError
	ActorTimeout
	ActorGoCtxError
	ActorInvalidPayload
	ActorInvalidProcess
)
View Source
const (
	REQUEST  = iota //kind, msgid, pid, method, args
	RESPONSE        //kind, msgid, err, args
	NOTIFY          //kind, pid, method, args

	TXN = 0x4
)

payload

View Source
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
)
View Source
const (
	SYSTEM_REQUEST = iota
)

Variables

View Source
var ConnCreationOnGoing error = fmt.Errorf("connection creation on going")

error

Functions

func AddrByNodeId

func AddrByNodeId(node_id proto.NodeId) (string, error)

func Call

func Call(id, method string, args ...interface{}) error

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 CallMR

func CallMR(id, method string, n_rv int, args ...interface{}) error

call RPC with number of return value. used for receiving multiple or no return value

func DateByUUID

func DateByUUID(id proto.UUID) time.Time

func Init

func Init(c *Config) error

API

func NodeIdByAddr

func NodeIdByAddr(addr string) (proto.NodeId, error)

func NodeIdByPid

func NodeIdByPid(pid proto.ProcessId) proto.NodeId

func RawCall

func RawCall(ctx context.Context, id, method string, n_rv int, args ...interface{}) error

same as CallMR but can receive go's context.

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.

func UUIDAt

func UUIDAt(t time.Time) proto.UUID

func UUIDBetween

func UUIDBetween(id proto.UUID, start, end time.Time) bool

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 CodecFactory interface {
	NewDecoder(c net.Conn) Decoder
	NewEncoder(c net.Conn) Encoder
}

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 Decoder

type Decoder interface {
	Decode(pl interface{}) error
}

codec interface

type DumpDecoder

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

func (*DumpDecoder) Read

func (d *DumpDecoder) Read(p []byte) (int, error)

type DumpEncoder

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

debug

func (*DumpEncoder) Write

func (e *DumpEncoder) Write(p []byte) (int, error)

type Encoder

type Encoder interface {
	Encode(pl interface{}) error
	Flush() error
}

type Executer

type Executer interface {
	Call(string, ...interface{}) (interface{}, error)
}

represents common rpc executer interface.

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

type JsonDecoder struct {
	json.Decoder
	// contains filtered or unexported fields
}

implementation of DecoderFactory/EncoderFactory, by json.

type JsonEncoder

type JsonEncoder struct {
	json.Encoder
	// contains filtered or unexported fields
}

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

type MsgpackDecoder struct {
	msgpack.Decoder
	// contains filtered or unexported fields
}

implementation of DecoderFactory/EncoderFactory, by msgpack.

func (*MsgpackDecoder) Decode

func (e *MsgpackDecoder) Decode(v interface{}) error

type MsgpackEncoder

type MsgpackEncoder struct {
	msgpack.Encoder
	// contains filtered or unexported fields
}

func (*MsgpackEncoder) Encode

func (e *MsgpackEncoder) Encode(v interface{}) error

func (*MsgpackEncoder) Flush

func (e *MsgpackEncoder) Flush() error

type Node

type Node struct {
	proto.Node
	// contains filtered or unexported fields
}

Account represents one user account

func (*Node) GenUUID

func (n *Node) GenUUID(t time.Time) uint64

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

type ProcessId proto.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

type UUID

type UUID proto.UUID

func NewId

func NewId() UUID

generate 64bit new uuid by using yue generate id facility. only after Init is called, it returns valid value.

Directories

Path Synopsis
Package YueProto is a generated protocol buffer package.
Package YueProto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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