core

package module
v0.0.0-...-1c5ad5c Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2016 License: MIT Imports: 21 Imported by: 0

README

Find documentation at docs.exis.io.

This project lives at https://github.com/exis-io/core.

Riffle Core

Riffle core logic, built into a library and linked with native wrappers.

Each language library consists of the core, a mantle, and a crust. All libraries share a core, most libraries have their own mantle, and each has its own crust. Mantles and the core are written in Go while crusts are written in native languages.

Currently, the following languages are supported:

  • Python
  • Javascript
  • Go
  • Swift

Support for Java, especially with Android, is coming quickly.

Documentation

Overview

package core allows communciation over the fabric.

See the official WAMP documentation at exis.io for more details on the protocol.

Index

Constants

View Source
const (
	Disconnected = iota
	Connected
	Ready
	Leaving
)
View Source
const (
	// A call could not be performed because there is no registered handler
	// for the endpoint.
	ErrNoSuchRegistration = "wamp.error.no_such_registration"

	// A call failed because the given argument types or values differ from
	// what the callee expects.
	ErrInvalidArgument = "wamp.error.invalid_argument"

	// The peer wants to close the session, sent as a GOODBYE reason.
	ErrCloseSession = "wamp.error.close_session"
)
View Source
const (
	LogLevelOff   int = 0
	LogLevelApp   int = 1
	LogLevelErr   int = 2
	LogLevelWarn  int = 3
	LogLevelInfo  int = 4
	LogLevelDebug int = 5
)
View Source
const (
	MessageTimeout time.Duration = 3 * time.Hour

	FabricLocal      = "ws://localhost:8000/ws"
	FabricDev        = "ws://ec2-52-26-83-61.us-west-2.compute.amazonaws.com:8000/ws"
	FabricSandbox    = "ws://sandbox.exis.io:8000/ws"
	FabricProduction = "wss://node.exis.io:8000/wss"

	RegistrarLocal      = "http://localhost:8880"
	RegistrarDev        = "http://ec2-52-26-83-61.us-west-2.compute.amazonaws.com:8880"
	RegistrarProduction = "https://node.exis.io:8880"

	CuminStrict = 2
	CuminLoose  = 1
	CuminOff    = 0
)

Variables

View Source
var (
	LogLevel      int    = 1
	Fabric        string = FabricProduction
	Registrar     string = RegistrarProduction
	CuminLevel    int    = CuminLoose
	UseUnsafeCert bool   = false
)
View Source
var (
	ShouldLogLineNumber = true // Print the line that emitted the log
)

Functions

func Application

func Application(format string, a ...interface{})

func Cumin

func Cumin(fn interface{}, args []interface{}) ([]interface{}, error)

Convert and apply args to arbitrary function fn

func Debug

func Debug(format string, a ...interface{})

func DecodePrivateKey

func DecodePrivateKey(data []byte) (*rsa.PrivateKey, error)

func Error

func Error(format string, a ...interface{})

func GetValueOf

func GetValueOf(x interface{}) reflect.Value

Wraps reflect.ValueOf to handle the case where an integer value is stored as a float64, as JSON unmarshal does.

func Info

func Info(format string, a ...interface{})

func MantleCall

func MantleCall(d Domain, endpoint string, cb uint64, eb uint64, args []interface{})

func MantleMarshall

func MantleMarshall(d Callback) string

Marshall data into json as it moves from the core to the crust

func MantleModel

func MantleModel(d Domain, target func(string, map[string]interface{}) ([]interface{}, error),
	collection string, query map[string]interface{}, cb uint64, eb uint64)

Access the model object functions. Note these methods have identical interfaces to allow this one method to do all the heavy lifting TODO: implement cuminication of these results

func MantlePublish

func MantlePublish(d Domain, endpoint string, cb uint64, eb uint64, args []interface{})

func MantleRegister

func MantleRegister(d Domain, endpoint string, cb uint64, eb uint64, handler uint64, types []interface{})

func MantleSubscribe

func MantleSubscribe(d Domain, endpoint string, cb uint64, eb uint64, handler uint64, types []interface{})

func MantleUnmarshal

func MantleUnmarshal(a string) []interface{}

Unmarshal json data in the mantle as it arrives from the crust

func MantleUnmarshalMap

func MantleUnmarshalMap(a string) map[string]interface{}

Sloppy deserialization, please merge

func MantleUnregister

func MantleUnregister(d Domain, endpoint string, cb uint64, eb uint64)

func MantleUnsubscribe

func MantleUnsubscribe(d Domain, endpoint string, cb uint64, eb uint64)

func NewApp

func NewApp() *app

func NewID

func NewID() uint64

func SignString

func SignString(msg string, key *rsa.PrivateKey) (string, error)

func SoftCumin

func SoftCumin(types []interface{}, args []interface{}) error

Checks the types of the provided positional arguments and the receiver.

func Warn

func Warn(format string, a ...interface{})

Types

type App

type App interface {
	ReceiveBytes([]byte)
	ReceiveMessage(message)

	Yield(uint64, []interface{})
	YieldError(uint64, string, []interface{})
	YieldOptions(request uint64, args []interface{}, options map[string]interface{})

	Close(string)
	ConnectionClosed(string)

	CallbackListen() Callback
	CallbackSend(uint64, ...interface{})

	SendHello() error

	// Temporary location, will move to security
	SetToken(string)
	GetToken() string
	LoadKey(string) error

	Login(Domain, ...string) (Domain, error)
	RegisterAccount(Domain, string, string, string, string) (bool, error)

	SetState(int)
	ShouldReconnect() bool
	NextRetryDelay() time.Duration
}

type Callback

type Callback struct {
	Id   uint64
	Args []interface{}
}

Sent up to the mantle and then the crust as callbacks are triggered

type Connection

type Connection interface {
	Send([]byte) error
	Close(string) error
	SetApp(App)
}

type Domain

type Domain interface {
	Subdomain(string) Domain
	LinkDomain(string) Domain

	Subscribe(string, uint64, []interface{}, map[string]interface{}) error
	Register(string, uint64, []interface{}, map[string]interface{}) error
	Publish(string, []interface{}, map[string]interface{}) error
	Call(string, []interface{}, map[string]interface{}) ([]interface{}, error)

	Unsubscribe(string) error
	Unregister(string) error

	CallExpects(uint64, []interface{})
	GetCallExpect(uint64) ([]interface{}, bool)
	RemoveCallExpect(uint64)

	Join(Connection) error
	Leave() error
	GetApp() App
	GetName() string
}

func NewDomain

func NewDomain(name string, a *app) Domain

Create a new domain. If no superdomain is provided, creates an app as well If the app exists, has a connection, and is connected then immediately call onJoin on that domain

type IdGenerator

type IdGenerator interface {
	NewID() uint64
}

An external generator of ids based on platform differences

var ExternalGenerator IdGenerator = nil

If this is set, core relies on this to generate IDs instead of its own logic

type InvalidURIError

type InvalidURIError string

func (InvalidURIError) Error

func (e InvalidURIError) Error() string

type Model

type Model interface {
	All(string, map[string]interface{}) ([]interface{}, error)
	Find(string, map[string]interface{}) ([]interface{}, error)
	Create(string, map[string]interface{}) ([]interface{}, error)
	Save(string, map[string]interface{}) ([]interface{}, error)
	Count(string, map[string]interface{}) ([]interface{}, error)
}

func SetSession

func SetSession(appDomain Domain) Model

Set a session and return a new model interface. The session must already be joined

type NoDestinationError

type NoDestinationError string

func (NoDestinationError) Error

func (e NoDestinationError) Error() string

type Serialization

type Serialization int

Directories

Path Synopsis
package name: riffle
package name: riffle

Jump to

Keyboard shortcuts

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