rony

package module
v0.16.25 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: BSD-3-Clause Imports: 18 Imported by: 23

README

Rony (Fast and Scalable RPC Framework)

GitHub release (latest SemVer including pre-releases)

About

Rony lets you create a clustered aware service easily. Checkout Wiki

Performance

Rony is very fast and with very low overhead. In a non-raft environment it adds < 25us latency, and in raft-enabled scenario around 1ms latency.

Rony has negligible memory footprint by reusing buffers and pooling.

BenchmarkEdgeServerMessageSerial
BenchmarkEdgeServerMessageSerial-16                       901370              1195 ns/op              87 B/op          2 allocs/op
BenchmarkEdgeServerMessageParallel
BenchmarkEdgeServerMessageParallel-16                    4521645               272 ns/op              83 B/op          2 allocs/op
BenchmarkEdgeServerWithRaftMessageSerial
BenchmarkEdgeServerWithRaftMessageSerial-16                 9541            132065 ns/op            5034 B/op        116 allocs/op
BenchmarkEdgeServerWithRaftMessageParallel
BenchmarkEdgeServerWithRaftMessageParallel-16             124658              8438 ns/op            4462 B/op         51 allocs/op

BenchmarkServerWithWebsocket-16            46514             25138 ns/op             691 B/op         19 allocs/op

Easy Setup for advanced scenarios
package main

import (
	"github.com/ronaksoft/rony"
	"github.com/ronaksoft/rony/edge"
	"os"
)

func main() {
	serverID := "UniqueServerID"
	edgeServer := edge.NewServer(serverID,
		edge.WithTcpGateway(edge.TcpGatewayConfig{
			Concurrency:   1000,
			MaxIdleTime:   0,
			ListenAddress: "0.0.0.0:80",
			ExternalAddrs: []string{"127.0.0.1:80"}, // ExternalAddr could be used when the server is behind proxy or nats
		}),
		edge.WithUdpTunnel(edge.UdpTunnelConfig{
			ListenAddress: "0.0.0.0:8080",
			MaxBodySize:   0,
			ExternalAddrs: nil,
		}),
		edge.WithGossipCluster(edge.GossipClusterConfig{
			Bootstrap:  true,
			ReplicaSet: 1,
			GossipPort: 7091,
		}),
	)

	service.RegisterSampleService(&service.SampleService{}, edgeServer)
	edgeServer.Start()

	edgeServer.ShutdownWithSignal(os.Kill)
}

This code does not run, please check example directory for working examples


Shoulders

Rony is made of big and popular packages. Without these great libraries building Rony was not possible.

Contribution

We need to make a clear and understandable documentation for Rony, so any help would be appreciated. We also appreciate benchmarking Rony against other platforms for common scenarios and will be cited.

TODOs
  • Auto-generate REST handlers
  • Auto-generate test units
  • Implement scenario tests using edgetest framework
  • Write Examples and Tutorials
  • Helper functions for dependency injection
  • Update constructors to use full name (breaks backward compatibility)
  • implement RAFT enabled store

Documentation

Index

Constants

View Source
const (
	MethodWild    = "*"
	MethodGet     = "GET"     // RFC 7231, 4.3.1
	MethodHead    = "HEAD"    // RFC 7231, 4.3.2
	MethodPost    = "POST"    // RFC 7231, 4.3.3
	MethodPut     = "PUT"     // RFC 7231, 4.3.4
	MethodPatch   = "PATCH"   // RFC 5789
	MethodDelete  = "DELETE"  // RFC 7231, 4.3.5
	MethodConnect = "CONNECT" // RFC 7231, 4.3.6
	MethodOptions = "OPTIONS" // RFC 7231, 4.3.7
	MethodTrace   = "TRACE"   // RFC 7231, 4.3.8
)

HTTP methods were copied from net/http.

View Source
const C_Edge uint64 = 3661905149145645056
View Source
const C_Edges uint64 = 3202852853167161344
View Source
const C_Error uint64 = 3300063058275074048
View Source
const C_GetAllNodes uint64 = 2426091802953969362
View Source
const C_GetNodes uint64 = 17614373553603896039
View Source
const C_HttpBody uint64 = 4148778432730789982
View Source
const C_KeyValue uint64 = 9712539143259722476
View Source
const C_MessageContainer uint64 = 8705479839606992738
View Source
const C_MessageEnvelope uint64 = 11385363697628734430
View Source
const C_Ping uint64 = 3584172304239689728
View Source
const C_Pong uint64 = 3584174915579805696
View Source
const C_Redirect uint64 = 12783312295490183931

Variables

View Source
var (
	RedirectReason_name = map[int32]string{
		0: "ReplicaSetSession",
		1: "ReplicaSetRequest",
		3: "Reserved1",
		4: "Reserved2",
		5: "Reserved3",
		6: "Reserved4",
	}
	RedirectReason_value = map[string]int32{
		"ReplicaSetSession": 0,
		"ReplicaSetRequest": 1,
		"Reserved1":         3,
		"Reserved2":         4,
		"Reserved3":         5,
		"Reserved4":         6,
	}
)

Enum value maps for RedirectReason.

View Source
var (
	// rony_cli generates the boiler plate code for client stub of rpc methods.
	//
	// optional CliOpt rony_cli = 50001;
	E_RonyCli = &file_options_proto_extTypes[0]
	// rony_no_client if is set then no client code will be generated. This flag is for internal usage.
	// DO NOT USE IT.
	//
	// optional bool rony_no_client = 50003;
	E_RonyNoClient = &file_options_proto_extTypes[1]
)

Extension fields to descriptorpb.ServiceOptions.

View Source
var (
	// rony_internal marks this method internal, hence only edges could execute this rpc through tunnel messages. In other words,
	// this command is not exposed to external clients connected through th gateway.
	//
	// optional bool rony_internal = 50002;
	E_RonyInternal = &file_options_proto_extTypes[2]
	// optional RestOpt rony_rest = 50003;
	E_RonyRest = &file_options_proto_extTypes[3]
)

Extension fields to descriptorpb.MethodOptions.

View Source
var (
	// optional ModelOpt rony_model = 50001;
	E_RonyModel = &file_options_proto_extTypes[4]
	// optional bool rony_envelope = 50031;
	E_RonyEnvelope = &file_options_proto_extTypes[5]
	// rony_skip_json will not generate de/serializer for JSON. If you use this option, then you need to
	// write them manually otherwise you will get compiler error.
	//
	// optional bool rony_skip_json = 50032;
	E_RonySkipJson = &file_options_proto_extTypes[6]
)

Extension fields to descriptorpb.MessageOptions.

View Source
var (
	// rony_index marks this field as an indexed field. Some queries will be generated for this indexed field.
	//
	// optional bool rony_index = 50001;
	E_RonyIndex = &file_options_proto_extTypes[7]
	// rony_default set the help text in generated cli client. This flag only works if rony_cobra_cmd is set
	// in the service.
	//
	// optional string rony_help = 50002;
	E_RonyHelp = &file_options_proto_extTypes[8]
	// rony_default set the default value in generated cli client. This flag only works if rony_cobra_cmd is set
	// in the service.
	//
	// optional string rony_default = 50003;
	E_RonyDefault = &file_options_proto_extTypes[9]
)

Extension fields to descriptorpb.FieldOptions.

View Source
var File_options_proto protoreflect.FileDescriptor
View Source
var PoolEdge = poolEdge{}
View Source
var PoolEdges = poolEdges{}
View Source
var PoolError = poolError{}
View Source
var PoolGetAllNodes = poolGetAllNodes{}
View Source
var PoolGetNodes = poolGetNodes{}
View Source
var PoolHttpBody = poolHttpBody{}
View Source
var PoolKeyValue = poolKeyValue{}
View Source
var PoolMessageContainer = poolMessageContainer{}
View Source
var PoolMessageEnvelope = poolMessageEnvelope{}
View Source
var PoolPing = poolPing{}
View Source
var PoolPong = poolPong{}
View Source
var PoolRedirect = poolRedirect{}

Functions

func RegisterPrometheus added in v0.5.8

func RegisterPrometheus(registerer prometheus.Registerer)

func SetLogLevel

func SetLogLevel(l LogLevel)

SetLogLevel is used for debugging purpose

Types

type CliOpt added in v0.15.0

type CliOpt struct {

	// protocol defines what protocol should client use to communicate with server.
	// POSSIBLE VALUES: "ws", "http"
	Protocol *string `protobuf:"bytes,1,opt,name=protocol" json:"protocol,omitempty"`
	// contains filtered or unexported fields
}

func (*CliOpt) Descriptor deprecated added in v0.15.0

func (*CliOpt) Descriptor() ([]byte, []int)

Deprecated: Use CliOpt.ProtoReflect.Descriptor instead.

func (*CliOpt) GetProtocol added in v0.15.0

func (x *CliOpt) GetProtocol() string

func (*CliOpt) ProtoMessage added in v0.15.0

func (*CliOpt) ProtoMessage()

func (*CliOpt) ProtoReflect added in v0.15.0

func (x *CliOpt) ProtoReflect() protoreflect.Message

func (*CliOpt) Reset added in v0.15.0

func (x *CliOpt) Reset()

func (*CliOpt) String added in v0.15.0

func (x *CliOpt) String() string

type Cluster added in v0.8.6

type Cluster interface {
	Start() error
	Shutdown()
	Join(addr ...string) (int, error)
	Leave() error
	Members() []ClusterMember
	MembersByReplicaSet(replicaSets ...uint64) []ClusterMember
	MemberByID(string) ClusterMember
	MemberByHash(uint64) ClusterMember
	ReplicaSet() uint64
	ServerID() string
	TotalReplicas() int
	Addr() string
	SetGatewayAddrs(hostPorts []string) error
	SetTunnelAddrs(hostPorts []string) error
	Subscribe(d ClusterDelegate)
}

Cluster is the component which create and present the whole cluster of Edge nodes.

type ClusterDelegate added in v0.9.0

type ClusterDelegate interface {
	OnJoin(hash uint64)
	OnLeave(hash uint64)
}

type ClusterMember added in v0.9.0

type ClusterMember interface {
	Proto(info *Edge) *Edge
	ServerID() string
	ReplicaSet() uint64
	GatewayAddr() []string
	TunnelAddr() []string
	Dial() (net.Conn, error)
}

type Conn added in v0.1.9

type Conn interface {
	ConnID() uint64
	ClientIP() string
	WriteBinary(streamID int64, data []byte) error
	// Persistent returns FALSE if this connection will be closed when edge.DispatchCtx has
	// been done. i.e. HTTP connections. It returns TRUE if this connection still alive when
	// edge.DispatchCtx has been done. i.e. WebSocket connections
	Persistent() bool
	Get(key string) interface{}
	Set(key string, val interface{})
	Walk(func(k string, v interface{}) bool)
}

Conn defines the Connection interface

type Edge added in v0.5.0

type Edge struct {
	ReplicaSet uint64   `protobuf:"varint,1,opt,name=ReplicaSet,proto3" json:"ReplicaSet,omitempty"`
	ServerID   string   `protobuf:"bytes,2,opt,name=ServerID,proto3" json:"ServerID,omitempty"`
	HostPorts  []string `protobuf:"bytes,3,rep,name=HostPorts,proto3" json:"HostPorts,omitempty"`
	// contains filtered or unexported fields
}

Edge

func (*Edge) Clone added in v0.12.0

func (x *Edge) Clone() *Edge

func (*Edge) DeepCopy added in v0.5.0

func (x *Edge) DeepCopy(z *Edge)

func (*Edge) Descriptor deprecated added in v0.5.0

func (*Edge) Descriptor() ([]byte, []int)

Deprecated: Use Edge.ProtoReflect.Descriptor instead.

func (*Edge) GetHostPorts added in v0.5.0

func (x *Edge) GetHostPorts() []string

func (*Edge) GetReplicaSet added in v0.5.0

func (x *Edge) GetReplicaSet() uint64

func (*Edge) GetServerID added in v0.5.0

func (x *Edge) GetServerID() string

func (*Edge) Marshal added in v0.5.0

func (x *Edge) Marshal() ([]byte, error)

func (*Edge) MarshalJSON added in v0.10.3

func (x *Edge) MarshalJSON() ([]byte, error)

func (*Edge) ProtoMessage added in v0.5.0

func (*Edge) ProtoMessage()

func (*Edge) ProtoReflect added in v0.5.0

func (x *Edge) ProtoReflect() protoreflect.Message

func (*Edge) Reset added in v0.5.0

func (x *Edge) Reset()

func (*Edge) String added in v0.5.0

func (x *Edge) String() string

func (*Edge) Unmarshal added in v0.5.0

func (x *Edge) Unmarshal(b []byte) error

func (*Edge) UnmarshalJSON added in v0.10.3

func (x *Edge) UnmarshalJSON(b []byte) error

type Edges added in v0.5.0

type Edges struct {
	Nodes []*Edge `protobuf:"bytes,1,rep,name=Nodes,proto3" json:"Nodes,omitempty"`
	// contains filtered or unexported fields
}

Edges

func (*Edges) Clone added in v0.12.0

func (x *Edges) Clone() *Edges

func (*Edges) DeepCopy added in v0.5.0

func (x *Edges) DeepCopy(z *Edges)

func (*Edges) Descriptor deprecated added in v0.5.0

func (*Edges) Descriptor() ([]byte, []int)

Deprecated: Use Edges.ProtoReflect.Descriptor instead.

func (*Edges) GetNodes added in v0.5.0

func (x *Edges) GetNodes() []*Edge

func (*Edges) Marshal added in v0.5.0

func (x *Edges) Marshal() ([]byte, error)

func (*Edges) MarshalJSON added in v0.10.3

func (x *Edges) MarshalJSON() ([]byte, error)

func (*Edges) ProtoMessage added in v0.5.0

func (*Edges) ProtoMessage()

func (*Edges) ProtoReflect added in v0.5.0

func (x *Edges) ProtoReflect() protoreflect.Message

func (*Edges) Reset added in v0.5.0

func (x *Edges) Reset()

func (*Edges) String added in v0.5.0

func (x *Edges) String() string

func (*Edges) Unmarshal added in v0.5.0

func (x *Edges) Unmarshal(b []byte) error

func (*Edges) UnmarshalJSON added in v0.10.3

func (x *Edges) UnmarshalJSON(b []byte) error

type Error

type Error struct {
	Code        string `protobuf:"bytes,1,opt,name=Code,proto3" json:"Code,omitempty"`
	Items       string `protobuf:"bytes,2,opt,name=Items,proto3" json:"Items,omitempty"`
	Description string `protobuf:"bytes,3,opt,name=Description,proto3" json:"Description,omitempty"`
	// contains filtered or unexported fields
}

Error

func (*Error) Clone added in v0.12.0

func (x *Error) Clone() *Error

func (*Error) DeepCopy

func (x *Error) DeepCopy(z *Error)

func (*Error) Descriptor deprecated

func (*Error) Descriptor() ([]byte, []int)

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) Error added in v0.2.4

func (x *Error) Error() string

Extra methods for Error

func (*Error) Expand added in v0.8.0

func (x *Error) Expand() (string, string)

func (*Error) GetCode

func (x *Error) GetCode() string

func (*Error) GetDescription added in v0.5.0

func (x *Error) GetDescription() string

func (*Error) GetItems

func (x *Error) GetItems() string

func (*Error) Marshal added in v0.0.17

func (x *Error) Marshal() ([]byte, error)

func (*Error) MarshalJSON added in v0.10.3

func (x *Error) MarshalJSON() ([]byte, error)

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

func (x *Error) ProtoReflect() protoreflect.Message

func (*Error) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

func (*Error) ToEnvelope added in v0.8.0

func (x *Error) ToEnvelope(me *MessageEnvelope)

func (*Error) Unmarshal

func (x *Error) Unmarshal(b []byte) error

func (*Error) UnmarshalJSON added in v0.10.3

func (x *Error) UnmarshalJSON(b []byte) error

type Gateway added in v0.8.6

type Gateway interface {
	Start()
	Run()
	Shutdown()
	GetConn(connID uint64) Conn
	Addr() []string
	Protocol() GatewayProtocol
	Subscribe(d GatewayDelegate)
}

Gateway defines the gateway interface where clients could connect and communicate with the Edge servers

type GatewayDelegate added in v0.16.0

type GatewayDelegate interface {
	OnConnect(c Conn, kvs ...*KeyValue)
	OnMessage(c Conn, streamID int64, data []byte)
	OnClose(c Conn)
}

type GatewayProtocol added in v0.9.0

type GatewayProtocol int32
const (
	Undefined GatewayProtocol = 0
	Dummy     GatewayProtocol = 1 << iota
	Http
	Websocket
	Quic
	Grpc
	TCP = Http | Websocket // Http & Websocket
)

func (GatewayProtocol) String added in v0.9.0

func (p GatewayProtocol) String() string

type GetAllNodes added in v0.7.4

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

GetNodes @Function @Return: Edges

func (*GetAllNodes) Clone added in v0.12.0

func (x *GetAllNodes) Clone() *GetAllNodes

func (*GetAllNodes) DeepCopy added in v0.7.4

func (x *GetAllNodes) DeepCopy(z *GetAllNodes)

func (*GetAllNodes) Descriptor deprecated added in v0.7.4

func (*GetAllNodes) Descriptor() ([]byte, []int)

Deprecated: Use GetAllNodes.ProtoReflect.Descriptor instead.

func (*GetAllNodes) Marshal added in v0.7.4

func (x *GetAllNodes) Marshal() ([]byte, error)

func (*GetAllNodes) MarshalJSON added in v0.10.3

func (x *GetAllNodes) MarshalJSON() ([]byte, error)

func (*GetAllNodes) ProtoMessage added in v0.7.4

func (*GetAllNodes) ProtoMessage()

func (*GetAllNodes) ProtoReflect added in v0.7.4

func (x *GetAllNodes) ProtoReflect() protoreflect.Message

func (*GetAllNodes) Reset added in v0.7.4

func (x *GetAllNodes) Reset()

func (*GetAllNodes) String added in v0.7.4

func (x *GetAllNodes) String() string

func (*GetAllNodes) Unmarshal added in v0.7.4

func (x *GetAllNodes) Unmarshal(b []byte) error

func (*GetAllNodes) UnmarshalJSON added in v0.10.3

func (x *GetAllNodes) UnmarshalJSON(b []byte) error

type GetNodes added in v0.1.5

type GetNodes struct {
	ReplicaSet []uint64 `protobuf:"varint,1,rep,packed,name=ReplicaSet,proto3" json:"ReplicaSet,omitempty"`
	// contains filtered or unexported fields
}

GetNodes @Function @Return: Edges

func (*GetNodes) Clone added in v0.12.0

func (x *GetNodes) Clone() *GetNodes

func (*GetNodes) DeepCopy added in v0.1.5

func (x *GetNodes) DeepCopy(z *GetNodes)

func (*GetNodes) Descriptor deprecated added in v0.1.5

func (*GetNodes) Descriptor() ([]byte, []int)

Deprecated: Use GetNodes.ProtoReflect.Descriptor instead.

func (*GetNodes) GetReplicaSet added in v0.1.5

func (x *GetNodes) GetReplicaSet() []uint64

func (*GetNodes) Marshal added in v0.1.5

func (x *GetNodes) Marshal() ([]byte, error)

func (*GetNodes) MarshalJSON added in v0.10.3

func (x *GetNodes) MarshalJSON() ([]byte, error)

func (*GetNodes) ProtoMessage added in v0.1.5

func (*GetNodes) ProtoMessage()

func (*GetNodes) ProtoReflect added in v0.1.5

func (x *GetNodes) ProtoReflect() protoreflect.Message

func (*GetNodes) Reset added in v0.1.5

func (x *GetNodes) Reset()

func (*GetNodes) String added in v0.1.5

func (x *GetNodes) String() string

func (*GetNodes) Unmarshal added in v0.1.5

func (x *GetNodes) Unmarshal(b []byte) error

func (*GetNodes) UnmarshalJSON added in v0.10.3

func (x *GetNodes) UnmarshalJSON(b []byte) error

type HttpBody added in v0.8.0

type HttpBody struct {
	ContentType string      `protobuf:"bytes,1,opt,name=ContentType,proto3" json:"ContentType,omitempty"`
	Header      []*KeyValue `protobuf:"bytes,2,rep,name=Header,proto3" json:"Header,omitempty"`
	Body        []byte      `protobuf:"bytes,3,opt,name=Body,proto3" json:"Body,omitempty"`
	// contains filtered or unexported fields
}

HttpBody used by REST proxies to fill the output.

func (*HttpBody) Clone added in v0.12.0

func (x *HttpBody) Clone() *HttpBody

func (*HttpBody) DeepCopy added in v0.8.0

func (x *HttpBody) DeepCopy(z *HttpBody)

func (*HttpBody) Descriptor deprecated added in v0.8.0

func (*HttpBody) Descriptor() ([]byte, []int)

Deprecated: Use HttpBody.ProtoReflect.Descriptor instead.

func (*HttpBody) GetBody added in v0.8.0

func (x *HttpBody) GetBody() []byte

func (*HttpBody) GetContentType added in v0.8.0

func (x *HttpBody) GetContentType() string

func (*HttpBody) GetHeader added in v0.8.0

func (x *HttpBody) GetHeader() []*KeyValue

func (*HttpBody) Marshal added in v0.8.0

func (x *HttpBody) Marshal() ([]byte, error)

func (*HttpBody) MarshalJSON added in v0.10.3

func (x *HttpBody) MarshalJSON() ([]byte, error)

func (*HttpBody) ProtoMessage added in v0.8.0

func (*HttpBody) ProtoMessage()

func (*HttpBody) ProtoReflect added in v0.8.0

func (x *HttpBody) ProtoReflect() protoreflect.Message

func (*HttpBody) Reset added in v0.8.0

func (x *HttpBody) Reset()

func (*HttpBody) String added in v0.8.0

func (x *HttpBody) String() string

func (*HttpBody) Unmarshal added in v0.8.0

func (x *HttpBody) Unmarshal(b []byte) error

func (*HttpBody) UnmarshalJSON added in v0.10.3

func (x *HttpBody) UnmarshalJSON(b []byte) error

type IMessage added in v0.16.5

type IMessage interface {
	proto.Message
	json.Marshaler
	json.Unmarshaler
}

type KeyValue

type KeyValue struct {
	Key   string `protobuf:"bytes,1,opt,name=Key,proto3" json:"Key,omitempty"`
	Value string `protobuf:"bytes,2,opt,name=Value,proto3" json:"Value,omitempty"`
	// contains filtered or unexported fields
}

KeyValue

func (*KeyValue) Clone added in v0.12.0

func (x *KeyValue) Clone() *KeyValue

func (*KeyValue) DeepCopy

func (x *KeyValue) DeepCopy(z *KeyValue)

func (*KeyValue) Descriptor deprecated

func (*KeyValue) Descriptor() ([]byte, []int)

Deprecated: Use KeyValue.ProtoReflect.Descriptor instead.

func (*KeyValue) GetKey

func (x *KeyValue) GetKey() string

func (*KeyValue) GetValue

func (x *KeyValue) GetValue() string

func (*KeyValue) Marshal added in v0.0.17

func (x *KeyValue) Marshal() ([]byte, error)

func (*KeyValue) MarshalJSON added in v0.10.3

func (x *KeyValue) MarshalJSON() ([]byte, error)

func (*KeyValue) ProtoMessage

func (*KeyValue) ProtoMessage()

func (*KeyValue) ProtoReflect

func (x *KeyValue) ProtoReflect() protoreflect.Message

func (*KeyValue) Reset

func (x *KeyValue) Reset()

func (*KeyValue) String

func (x *KeyValue) String() string

func (*KeyValue) Unmarshal

func (x *KeyValue) Unmarshal(b []byte) error

func (*KeyValue) UnmarshalJSON added in v0.10.3

func (x *KeyValue) UnmarshalJSON(b []byte) error

type LocalDB added in v0.12.2

type LocalDB = badger.DB

type LogLevel added in v0.10.3

type LogLevel = log.Level

type MessageContainer

type MessageContainer struct {
	Length    int32              `protobuf:"varint,1,opt,name=Length,proto3" json:"Length,omitempty"`
	Envelopes []*MessageEnvelope `protobuf:"bytes,2,rep,name=Envelopes,proto3" json:"Envelopes,omitempty"`
	// SyncRun makes the execution in sequence if it is TRUE
	SyncRun bool `protobuf:"varint,3,opt,name=SyncRun,proto3" json:"SyncRun,omitempty"`
	// contains filtered or unexported fields
}

MessageContainer This type of message will be used to send multi messages inside a single container message

func (*MessageContainer) Add added in v0.6.11

func (x *MessageContainer) Add(reqID uint64, constructor uint64, p proto.Message, kvs ...*KeyValue)

Extra methods for MessageContainer

func (*MessageContainer) Clone added in v0.12.0

func (x *MessageContainer) Clone() *MessageContainer

func (*MessageContainer) DeepCopy

func (x *MessageContainer) DeepCopy(z *MessageContainer)

func (*MessageContainer) Descriptor deprecated

func (*MessageContainer) Descriptor() ([]byte, []int)

Deprecated: Use MessageContainer.ProtoReflect.Descriptor instead.

func (*MessageContainer) GetEnvelopes

func (x *MessageContainer) GetEnvelopes() []*MessageEnvelope

func (*MessageContainer) GetLength

func (x *MessageContainer) GetLength() int32

func (*MessageContainer) GetSyncRun added in v0.14.1

func (x *MessageContainer) GetSyncRun() bool

func (*MessageContainer) Marshal added in v0.0.17

func (x *MessageContainer) Marshal() ([]byte, error)

func (*MessageContainer) MarshalJSON added in v0.10.3

func (x *MessageContainer) MarshalJSON() ([]byte, error)

func (*MessageContainer) ProtoMessage

func (*MessageContainer) ProtoMessage()

func (*MessageContainer) ProtoReflect

func (x *MessageContainer) ProtoReflect() protoreflect.Message

func (*MessageContainer) Reset

func (x *MessageContainer) Reset()

func (*MessageContainer) String

func (x *MessageContainer) String() string

func (*MessageContainer) Unmarshal

func (x *MessageContainer) Unmarshal(b []byte) error

func (*MessageContainer) UnmarshalJSON added in v0.10.3

func (x *MessageContainer) UnmarshalJSON(b []byte) error

type MessageEnvelope

type MessageEnvelope struct {
	Constructor uint64      `protobuf:"varint,1,opt,name=Constructor,proto3" json:"Constructor,omitempty"`
	RequestID   uint64      `protobuf:"fixed64,2,opt,name=RequestID,proto3" json:"RequestID,omitempty"`
	JsonEncoded bool        `protobuf:"varint,3,opt,name=JsonEncoded,proto3" json:"JsonEncoded,omitempty"`
	Message     []byte      `protobuf:"bytes,4,opt,name=Message,proto3" json:"Message,omitempty"`
	Auth        []byte      `protobuf:"bytes,8,opt,name=Auth,proto3" json:"Auth,omitempty"`
	Header      []*KeyValue `protobuf:"bytes,10,rep,name=Header,proto3" json:"Header,omitempty"`
	// contains filtered or unexported fields
}

MessageEnvelope This type of message will be used to contain another ProtoBuffer Message inside

func (*MessageEnvelope) Append added in v0.16.0

func (x *MessageEnvelope) Append(key, val string)

func (*MessageEnvelope) Carrier added in v0.16.0

func (x *MessageEnvelope) Carrier() *envelopeCarrier

Carrier wraps the MessageEnvelope into an envelope carrier which is useful for cross-cutting tracing. With this method, instrumentation packages can pass the trace info into the wire. Rony has builtin support, and you do not need to use this function explicitly. Check edge.WithTracer option to enable tracing

func (*MessageEnvelope) Clone

func (x *MessageEnvelope) Clone() *MessageEnvelope

func (*MessageEnvelope) DeepCopy

func (x *MessageEnvelope) DeepCopy(z *MessageEnvelope)

func (*MessageEnvelope) Descriptor deprecated

func (*MessageEnvelope) Descriptor() ([]byte, []int)

Deprecated: Use MessageEnvelope.ProtoReflect.Descriptor instead.

func (*MessageEnvelope) Fill

func (x *MessageEnvelope) Fill(reqID uint64, constructor uint64, p proto.Message, kvs ...*KeyValue)

func (*MessageEnvelope) Get added in v0.0.18

func (x *MessageEnvelope) Get(key, defaultVal string) string

func (*MessageEnvelope) GetAuth

func (x *MessageEnvelope) GetAuth() []byte

func (*MessageEnvelope) GetConstructor

func (x *MessageEnvelope) GetConstructor() uint64

func (*MessageEnvelope) GetHeader

func (x *MessageEnvelope) GetHeader() []*KeyValue

func (*MessageEnvelope) GetJsonEncoded added in v0.16.5

func (x *MessageEnvelope) GetJsonEncoded() bool

func (*MessageEnvelope) GetMessage

func (x *MessageEnvelope) GetMessage() []byte

func (*MessageEnvelope) GetRequestID

func (x *MessageEnvelope) GetRequestID() uint64

func (*MessageEnvelope) Marshal added in v0.0.17

func (x *MessageEnvelope) Marshal() ([]byte, error)

func (*MessageEnvelope) MarshalJSON added in v0.10.3

func (x *MessageEnvelope) MarshalJSON() ([]byte, error)

func (*MessageEnvelope) ProtoMessage

func (*MessageEnvelope) ProtoMessage()

func (*MessageEnvelope) ProtoReflect

func (x *MessageEnvelope) ProtoReflect() protoreflect.Message

func (*MessageEnvelope) Reset

func (x *MessageEnvelope) Reset()

func (*MessageEnvelope) Set added in v0.0.18

func (x *MessageEnvelope) Set(KVs ...*KeyValue)

func (*MessageEnvelope) String

func (x *MessageEnvelope) String() string

func (*MessageEnvelope) Unmarshal

func (x *MessageEnvelope) Unmarshal(b []byte) error

func (*MessageEnvelope) UnmarshalJSON added in v0.10.3

func (x *MessageEnvelope) UnmarshalJSON(b []byte) error

func (*MessageEnvelope) Unwrap added in v0.12.45

func (x *MessageEnvelope) Unwrap() (protoreflect.Message, error)

type MessageEnvelopeJSON added in v0.16.5

type MessageEnvelopeJSON struct {
	RequestID   uint64            `json:"requestId"`
	Header      map[string]string `json:"header,omitempty"`
	Constructor string            `json:"cmd"`
	Message     json.RawMessage   `json:"message"`
}

MessageEnvelopeJSON is the JSON representation of MessageEnvelope.

type ModelOpt added in v0.15.0

type ModelOpt struct {

	// singleton marks this model as a singleton.
	Singleton *bool `protobuf:"varint,1,opt,name=singleton" json:"singleton,omitempty"`
	// global_datasource generates the code for remote repository
	// POSSIBLE VALUES: cql, sql
	GlobalDatasource *string `protobuf:"bytes,2,opt,name=global_datasource,json=globalDatasource" json:"global_datasource,omitempty"`
	// local_datasource generates the code for local repository
	// POSSIBLE VALUES: store, cql, sql
	LocalDatasource *string `protobuf:"bytes,3,opt,name=local_datasource,json=localDatasource" json:"local_datasource,omitempty"`
	// table a virtual table presentation to hold instances of this message, like rows in a table
	// PRIMARY KEY FORMAT: ( (partitionKey1, partitionKey2, ...), clusteringKey1, clusteringKey2, ...)
	Table *PrimaryKeyOpt `protobuf:"bytes,4,opt,name=table" json:"table,omitempty"`
	// view creates a materialized view of the aggregate based on the primary key.
	// PRIMARY KEY FORMAT: ( (partitionKey1, partitionKey2, ...), clusteringKey1, clusteringKey2, ...)
	// NOTE: The primary key of the view must contains all the primary key items of the table. They don't need to
	//           follow the same order as table. for example the following is correct:
	//                  table = ((a, b), c)
	//                  view = ((c, a),  d, b)
	View []*PrimaryKeyOpt `protobuf:"bytes,5,rep,name=view" json:"view,omitempty"`
	// contains filtered or unexported fields
}

ModelOpt holds all the information if you want to create a model from your proto message.

func (*ModelOpt) Descriptor deprecated added in v0.15.0

func (*ModelOpt) Descriptor() ([]byte, []int)

Deprecated: Use ModelOpt.ProtoReflect.Descriptor instead.

func (*ModelOpt) GetGlobalDatasource added in v0.15.0

func (x *ModelOpt) GetGlobalDatasource() string

func (*ModelOpt) GetLocalDatasource added in v0.15.0

func (x *ModelOpt) GetLocalDatasource() string

func (*ModelOpt) GetSingleton added in v0.15.0

func (x *ModelOpt) GetSingleton() bool

func (*ModelOpt) GetTable added in v0.15.0

func (x *ModelOpt) GetTable() *PrimaryKeyOpt

func (*ModelOpt) GetView added in v0.15.0

func (x *ModelOpt) GetView() []*PrimaryKeyOpt

func (*ModelOpt) ProtoMessage added in v0.15.0

func (*ModelOpt) ProtoMessage()

func (*ModelOpt) ProtoReflect added in v0.15.0

func (x *ModelOpt) ProtoReflect() protoreflect.Message

func (*ModelOpt) Reset added in v0.15.0

func (x *ModelOpt) Reset()

func (*ModelOpt) String added in v0.15.0

func (x *ModelOpt) String() string

type Ping added in v0.12.56

type Ping struct {
	ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
	// contains filtered or unexported fields
}

func (*Ping) Clone added in v0.12.56

func (x *Ping) Clone() *Ping

func (*Ping) DeepCopy added in v0.12.56

func (x *Ping) DeepCopy(z *Ping)

func (*Ping) Descriptor deprecated added in v0.12.56

func (*Ping) Descriptor() ([]byte, []int)

Deprecated: Use Ping.ProtoReflect.Descriptor instead.

func (*Ping) GetID added in v0.12.56

func (x *Ping) GetID() int64

func (*Ping) Marshal added in v0.12.56

func (x *Ping) Marshal() ([]byte, error)

func (*Ping) MarshalJSON added in v0.12.56

func (x *Ping) MarshalJSON() ([]byte, error)

func (*Ping) ProtoMessage added in v0.12.56

func (*Ping) ProtoMessage()

func (*Ping) ProtoReflect added in v0.12.56

func (x *Ping) ProtoReflect() protoreflect.Message

func (*Ping) Reset added in v0.12.56

func (x *Ping) Reset()

func (*Ping) String added in v0.12.56

func (x *Ping) String() string

func (*Ping) Unmarshal added in v0.12.56

func (x *Ping) Unmarshal(b []byte) error

func (*Ping) UnmarshalJSON added in v0.12.56

func (x *Ping) UnmarshalJSON(b []byte) error

type Pong added in v0.12.56

type Pong struct {
	ID int64 `protobuf:"varint,2,opt,name=ID,proto3" json:"ID,omitempty"`
	// contains filtered or unexported fields
}

func (*Pong) Clone added in v0.12.56

func (x *Pong) Clone() *Pong

func (*Pong) DeepCopy added in v0.12.56

func (x *Pong) DeepCopy(z *Pong)

func (*Pong) Descriptor deprecated added in v0.12.56

func (*Pong) Descriptor() ([]byte, []int)

Deprecated: Use Pong.ProtoReflect.Descriptor instead.

func (*Pong) GetID added in v0.12.56

func (x *Pong) GetID() int64

func (*Pong) Marshal added in v0.12.56

func (x *Pong) Marshal() ([]byte, error)

func (*Pong) MarshalJSON added in v0.12.56

func (x *Pong) MarshalJSON() ([]byte, error)

func (*Pong) ProtoMessage added in v0.12.56

func (*Pong) ProtoMessage()

func (*Pong) ProtoReflect added in v0.12.56

func (x *Pong) ProtoReflect() protoreflect.Message

func (*Pong) Reset added in v0.12.56

func (x *Pong) Reset()

func (*Pong) String added in v0.12.56

func (x *Pong) String() string

func (*Pong) Unmarshal added in v0.12.56

func (x *Pong) Unmarshal(b []byte) error

func (*Pong) UnmarshalJSON added in v0.12.56

func (x *Pong) UnmarshalJSON(b []byte) error

type PrimaryKeyOpt added in v0.12.0

type PrimaryKeyOpt struct {
	PartKey []string `protobuf:"bytes,1,rep,name=part_key,json=partKey" json:"part_key,omitempty"`
	SortKey []string `protobuf:"bytes,2,rep,name=sort_key,json=sortKey" json:"sort_key,omitempty"`
	// Alias could be used to override the name of materialized view. If this is not set, Rony automatically
	// generates for you.
	Alias *string `protobuf:"bytes,4,opt,name=alias" json:"alias,omitempty"`
	// contains filtered or unexported fields
}

PrimaryKeyOpt is the container for aggregate primary key settings. It is going to replace old rony_aggregate_table & rony_aggregate_view options.

func (*PrimaryKeyOpt) Descriptor deprecated added in v0.12.0

func (*PrimaryKeyOpt) Descriptor() ([]byte, []int)

Deprecated: Use PrimaryKeyOpt.ProtoReflect.Descriptor instead.

func (*PrimaryKeyOpt) GetAlias added in v0.12.0

func (x *PrimaryKeyOpt) GetAlias() string

func (*PrimaryKeyOpt) GetPartKey added in v0.12.0

func (x *PrimaryKeyOpt) GetPartKey() []string

func (*PrimaryKeyOpt) GetSortKey added in v0.12.0

func (x *PrimaryKeyOpt) GetSortKey() []string

func (*PrimaryKeyOpt) ProtoMessage added in v0.12.0

func (*PrimaryKeyOpt) ProtoMessage()

func (*PrimaryKeyOpt) ProtoReflect added in v0.12.0

func (x *PrimaryKeyOpt) ProtoReflect() protoreflect.Message

func (*PrimaryKeyOpt) Reset added in v0.12.0

func (x *PrimaryKeyOpt) Reset()

func (*PrimaryKeyOpt) String added in v0.12.0

func (x *PrimaryKeyOpt) String() string

type Redirect

type Redirect struct {
	Reason    RedirectReason `protobuf:"varint,100,opt,name=Reason,proto3,enum=rony.RedirectReason" json:"Reason,omitempty"`
	Edges     []*Edge        `protobuf:"bytes,2,rep,name=Edges,proto3" json:"Edges,omitempty"`
	WaitInSec uint32         `protobuf:"varint,3,opt,name=WaitInSec,proto3" json:"WaitInSec,omitempty"`
	// contains filtered or unexported fields
}

Redirect

func (*Redirect) Clone added in v0.12.0

func (x *Redirect) Clone() *Redirect

func (*Redirect) DeepCopy

func (x *Redirect) DeepCopy(z *Redirect)

func (*Redirect) Descriptor deprecated

func (*Redirect) Descriptor() ([]byte, []int)

Deprecated: Use Redirect.ProtoReflect.Descriptor instead.

func (*Redirect) GetEdges added in v0.7.1

func (x *Redirect) GetEdges() []*Edge

func (*Redirect) GetReason added in v0.1.5

func (x *Redirect) GetReason() RedirectReason

func (*Redirect) GetWaitInSec

func (x *Redirect) GetWaitInSec() uint32

func (*Redirect) Marshal added in v0.0.17

func (x *Redirect) Marshal() ([]byte, error)

func (*Redirect) MarshalJSON added in v0.10.3

func (x *Redirect) MarshalJSON() ([]byte, error)

func (*Redirect) ProtoMessage

func (*Redirect) ProtoMessage()

func (*Redirect) ProtoReflect

func (x *Redirect) ProtoReflect() protoreflect.Message

func (*Redirect) Reset

func (x *Redirect) Reset()

func (*Redirect) String

func (x *Redirect) String() string

func (*Redirect) Unmarshal

func (x *Redirect) Unmarshal(b []byte) error

func (*Redirect) UnmarshalJSON added in v0.10.3

func (x *Redirect) UnmarshalJSON(b []byte) error

type RedirectReason added in v0.1.5

type RedirectReason int32

RedirectReason

const (
	RedirectReason_ReplicaSetSession RedirectReason = 0
	RedirectReason_ReplicaSetRequest RedirectReason = 1
	RedirectReason_Reserved1         RedirectReason = 3
	RedirectReason_Reserved2         RedirectReason = 4
	RedirectReason_Reserved3         RedirectReason = 5
	RedirectReason_Reserved4         RedirectReason = 6
)

func (RedirectReason) Descriptor added in v0.1.5

func (RedirectReason) Enum added in v0.1.5

func (x RedirectReason) Enum() *RedirectReason

func (RedirectReason) EnumDescriptor deprecated added in v0.1.5

func (RedirectReason) EnumDescriptor() ([]byte, []int)

Deprecated: Use RedirectReason.Descriptor instead.

func (RedirectReason) Number added in v0.1.5

func (RedirectReason) String added in v0.1.5

func (x RedirectReason) String() string

func (RedirectReason) Type added in v0.1.5

type RestConn added in v0.10.0

type RestConn interface {
	Conn
	ReadHeader(key string) string
	WriteStatus(status int)
	WriteHeader(key, value string)
	MultiPart() (*multipart.Form, error)
	RequestURI() string
	Schema() string
	Method() string
	Host() string
	Path() string
	Body() []byte
	Redirect(statusCode int, newHostPort string)
	RedirectURL(statusCode int, newURL string)
}

RestConn is same as Conn, but it supports REST format apis.

type RestOpt added in v0.10.3

type RestOpt struct {

	// method identifies the HTTP command: i.e. 'get', 'post', 'put', ...
	Method *string `protobuf:"bytes,1,req,name=method" json:"method,omitempty"`
	// path identifies the path that this RPC method will be available as REST endpoint.
	Path *string `protobuf:"bytes,2,req,name=path" json:"path,omitempty"`
	// bind_path_variables is a list of pair of bindings. For example if we have a path '/part1/:var1/:var2'
	// and we want to bind 'var1' to field 'fieldVar1': "var1=fieldVar1"
	BindPathParam []string `protobuf:"bytes,3,rep,name=bind_path_param,json=bindPathParam" json:"bind_path_param,omitempty"`
	// bind_query_param is a list of pair of bindings. For example if we have a query param var1
	// and we want to bind 'var1' to field 'fieldVar1': "var1=fieldVar1"
	BindQueryParam []string `protobuf:"bytes,4,rep,name=bind_query_param,json=bindQueryParam" json:"bind_query_param,omitempty"`
	// json_encode if is set then input and output data are json encoded version of the proto messages
	JsonEncode *bool `protobuf:"varint,5,opt,name=json_encode,json=jsonEncode" json:"json_encode,omitempty"`
	// contains filtered or unexported fields
}

RestOpt is the container message for all the required and optional parameters for REST setup. By adding 'rony_rest' option to the method definition a REST wrapper will be generated for that method and that RPC handler will become accessible using REST endpoint.

func (*RestOpt) Descriptor deprecated added in v0.10.3

func (*RestOpt) Descriptor() ([]byte, []int)

Deprecated: Use RestOpt.ProtoReflect.Descriptor instead.

func (*RestOpt) GetBindPathParam added in v0.14.34

func (x *RestOpt) GetBindPathParam() []string

func (*RestOpt) GetBindQueryParam added in v0.14.34

func (x *RestOpt) GetBindQueryParam() []string

func (*RestOpt) GetJsonEncode added in v0.10.3

func (x *RestOpt) GetJsonEncode() bool

func (*RestOpt) GetMethod added in v0.10.3

func (x *RestOpt) GetMethod() string

func (*RestOpt) GetPath added in v0.10.3

func (x *RestOpt) GetPath() string

func (*RestOpt) ProtoMessage added in v0.10.3

func (*RestOpt) ProtoMessage()

func (*RestOpt) ProtoReflect added in v0.10.3

func (x *RestOpt) ProtoReflect() protoreflect.Message

func (*RestOpt) Reset added in v0.10.3

func (x *RestOpt) Reset()

func (*RestOpt) String added in v0.10.3

func (x *RestOpt) String() string

type Router added in v0.14.1

type Router interface {
	Set(entityID string, replicaSet uint64, replace bool) error
	Get(entityID string) (replicaSet uint64, err error)
}

Router could be used by Edge servers to find entities and redirect clients to the right Edge server.

type StoreTxn added in v0.9.0

type StoreTxn = badger.Txn

type Tunnel added in v0.8.6

type Tunnel interface {
	Start()
	Run()
	Shutdown()
	Addr() []string
}

Tunnel provides the communication channel between Edge servers. Tunnel is similar to Gateway in functionalities. However, Tunnel should be optimized for inter-communication between Edge servers, and Gateway is optimized for client-server communications.

Directories

Path Synopsis
cmd
example
internal
gateway/tcp/util
Package wsutil provides utilities for working with WebSocket protocol.
Package wsutil provides utilities for working with WebSocket protocol.
msg
parser
Package parse builds parse trees for templates as defined by text/template and html/template.
Package parse builds parse trees for templates as defined by text/template and html/template.
buf

Jump to

Keyboard shortcuts

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