rpc

package module
v0.0.0-...-9768b48 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: MIT Imports: 23 Imported by: 0

README

rpc

RPC framework of microserver based on tygo(protobuf).

Documentation

Index

Constants

View Source
const (
	IDENT_RUID = iota
	IDENT_UUID
	IDENT_STRID
)
View Source
const (
	SYMBOL_GATE     = "GATE"
	SYMBOL_HUB      = "HUB"
	SYMBOL_CREATE   = "CREATE"
	SYMBOL_DESTROY  = "DESTROY"
	SYMBOL_SYNCHRON = "SYNCHRON"
	SYMBOL_NOTIFY   = "NOTIFY"
	SYMBOL_OBSERVE  = "OBSERVE"
	SYMBOL_IGNORE   = "IGNORE"
)
View Source
const CLIENT_ENTITY_FMT = "%sClient"
View Source
const (
	ENTITY_CODE = `` /* 1781-byte string literal not displayed */

)
View Source
const PY_HEADER = `#-*- coding: utf-8 -*-
# Generated by ibelie-rpc.  DO NOT EDIT!
`

Variables

View Source
var (
	SYMBOL_SESSION string
	CREATE_SESSION []byte
	HANDSHAKE_DATA []byte
	GATE_SYMBOLS   []string
	GATE_SYMDICT   = make(map[string]uint64)
)
View Source
var (
	FMT_PKG   = map[string]string{"fmt": ""}
	STR_PKG   = map[string]string{"strings": ""}
	LOCAL_PKG = map[string]string{
		"fmt":                    "",
		"sync":                   "",
		"github.com/ibelie/rpc":  "",
		"github.com/ibelie/ruid": "",
		"github.com/ibelie/tygo": "",
	}
	PROP_PRE = []tygo.Type{tygo.SimpleType_SYMBOL, tygo.SimpleType_SYMBOL}
	DELEGATE = "Delegate"
)
View Source
var (
	SRC_PATH = path.Join(os.Getenv("GOPATH"), "src")
	PKG_PATH = reflect.TypeOf(Depend{}).PkgPath()
)
View Source
var ClientEntityCache = make(map[string]string)
View Source
var ENTITY_PKG = map[string]string{
	"github.com/ibelie/rpc":  "",
	"github.com/ibelie/ruid": "",
	"github.com/ibelie/tygo": "",
}
View Source
var GateInst = GateImpl{/* contains filtered or unexported fields */}
View Source
var HubInst = HubImpl{/* contains filtered or unexported fields */}
View Source
var IDENT_PKG = [][2]string{
	[2]string{"github.com/ibelie/ruid", "ruid.RUIdent"},
	[2]string{"github.com/ibelie/rpc/uuid", "uuid.UUIdent"},
	[2]string{"github.com/ibelie/rpc/strid", "strid.STRIdent"},
}
View Source
var JSID_BYTESIZE = []func(string) string{
	func(value string) string {
		return fmt.Sprintf("8")
	},
	func(value string) string {
		return fmt.Sprintf("16")
	},
	func(value string) string {
		return fmt.Sprintf("ibelie.tyts.String.ByteSize(%s, 0, false)", value)
	},
}
View Source
var JSID_READ = []func(string) string{
	func(protobuf string) string {
		return fmt.Sprintf("%s.ReadBase64(8)", protobuf)
	},
	func(protobuf string) string {
		return fmt.Sprintf("%s.ReadBase64(16)", protobuf)
	},
	func(protobuf string) string {
		return fmt.Sprintf("ibelie.tyts.String.Deserialize(null, %s)", protobuf)
	},
}
View Source
var JSID_REQUIRE = []string{
	"",
	"",
	`
	goog.require('ibelie.tyts.String');
`,
}
View Source
var JSID_WRITE = []func(string, string) string{
	func(protobuf string, value string) string {
		return fmt.Sprintf("%s.WriteBase64(%s)", protobuf, value)
	},
	func(protobuf string, value string) string {
		return fmt.Sprintf("%s.WriteBase64(%s)", protobuf, value)
	},
	func(protobuf string, value string) string {
		return fmt.Sprintf("ibelie.tyts.String.Serialize(%s, 0, false, %s)", value, protobuf)
	},
}
View Source
var JSID_ZERO = []string{
	ruid.ZERO.String(),
	uuid.ZERO.String(),
	strid.ZERO.String(),
}

Functions

func DeserializeDispatch

func DeserializeDispatch(data []byte) (observers []ruid.ID, param []byte, err error)

func DeserializeGhosts

func DeserializeGhosts(data []byte) (ghosts []ruid.ID, err error)

func DeserializeRequest

func DeserializeRequest(data []byte) (i ruid.ID, ss []string, m string, p []byte, err error)

func DeserializeSessionGate

func DeserializeSessionGate(data []byte) (session ruid.ID, gate string, err error)

func Gate

func Gate(address string, session string, version [16]byte, symbols []string, network Network)

func Go

func Go(dir string, types []tygo.Type)

func IDENT_FromString

func IDENT_FromString(name string) int

func Inject

func Inject(dir string, filename string, pkgname string, types []tygo.Type, _ []tygo.Type, _ string)

func Python

func Python(identName string, input string, pyOut string, goOut string, ignore []string)

func ReplaceEntity

func ReplaceEntity(dir string, filename string, pkgname string, types []tygo.Type, _ []tygo.Type, _ string)

func ReserializeComponents

func ReserializeComponents(components [][]byte) (size int, cs []uint64, ds [][]byte, err error)

func ReserializeNotify

func ReserializeNotify(method string, data []byte) (param []byte, err error)

func SerializeDispatch

func SerializeDispatch(observers map[ruid.ID]bool, param []byte) (data []byte)

func SerializeGhosts

func SerializeGhosts(ghosts []ruid.ID) (data []byte)

func SerializeRequest

func SerializeRequest(i ruid.ID, ss []string, m string, p []byte) (data []byte)

func SerializeSynchron

func SerializeSynchron(i ruid.ID, components [][]byte, handshake []byte) (data []byte, err error)

func Typescript

func Typescript(identName string, tsOut string, goOut string, inputs []string)

Types

type Behavior

type Behavior struct {
	Name       string
	Module     string
	Methods    []string
	Entities   []string
	Components []*Component
}

type Component

type Component struct {
	Name     string
	Path     string
	Protocol *tygo.Object
	Service  *doc.Type
}

type Connection

type Connection interface {
	Address() string
	Send([]byte) error
	Receive() ([]byte, error)
	Close() error
}

type Depend

type Depend struct {
	Path     string
	Services []string
}

func Extract

func Extract(dir string) (pkgname string, depends []*Depend)

type Entity

type Entity struct {
	Name       string
	Behaviors  []*Behavior
	Components []*Component
}

type GateImpl

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

func (*GateImpl) Procedure

func (s *GateImpl) Procedure(i ruid.ID, m string, param []byte) (result []byte, err error)

type HubImpl

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

func (*HubImpl) Procedure

func (s *HubImpl) Procedure(i ruid.ID, m string, param []byte) (result []byte, err error)

type Network

type Network interface {
	Connect(string) Connection
	Serve(string, func(Connection))
}

type Node

type Node struct {
	Addr string
	Srvs []string
}

type Register

type Register func(Server) (string, Service)

type Server

type Server interface {
	Serve()
	GetNode() *Node
	Add(string, *Node)
	Remove(string)
	Address() string
	Register(...*Node)
	ZeroID() ruid.ID
	ServerID() ruid.ID
	DeserializeID(*tygo.ProtoBuf) (ruid.ID, error)
	Notify(ruid.ID, ruid.ID, string, []byte) error
	Message(ruid.ID, ruid.ID, ruid.ID, string, []byte) ([]byte, error)
	Distribute(ruid.ID, ruid.ID, string, string, []byte) ([][]byte, error)
	Procedure(ruid.ID, ruid.ID, string, string, string, []byte) ([]byte, error)
	Request(string, ruid.ID, string, []byte, ...string) ([][]byte, error)
}

func NewServer

func NewServer(address string, routes map[string]map[string]bool,
	ident ruid.Ident, network Network, rs ...Register) Server

type Service

type Service interface {
	Procedure(ruid.ID, string, []byte) ([]byte, error)
}

func GateService

func GateService(_ Server) (string, Service)

func HubService

func HubService(_ Server) (string, Service)

Directories

Path Synopsis
Package uuid provides implementation of Universally Unique Identifier (UUID).
Package uuid provides implementation of Universally Unique Identifier (UUID).

Jump to

Keyboard shortcuts

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