rony

package module
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: BSD-3-Clause Imports: 17 Imported by: 23

README

RONY (Fast and Scalable RPC Framework)


Rony lets you create a clustered aware service easily. Basically when your write a service with Rony framework, you develop two interfaces one is for the client side which clients of your service connect and communicate. We call it 'Gateway'. The other interface communicates with other instances in the cluster which we call it 'Tunnel'.

Basically when you are building your service with Rony you spin up an 'Edge' server. Each edge server has three components which you can enable them if you need to. ' Gateway', 'Tunnel' and 'Cluster'. You cannot enable 'Tunnel' without enabling 'Cluster'.

Each Edge server could be member of a replica set, if cluster is enabled. Edge servers which are in same replica set then they are replicated of each other. This replication is done by Raft protocol. Hence, only one of the edge servers in a replica set is the leader, and the rest are followers.

Each Edge server could have its 'Tunnel' component enabled. This is how the edge servers could communicate with each other. For example, imagine you have a request from a client connecting to an edge with replica set to '1' but to return the response we need to execute a command on a edge in replica set '2'. This could be easily done by using the ' Tunnel' features in Rony.

When we want to write a service to support sharding and replication, developers need to write a lot of code to manage their communication and how to write the code to handle these interactions between services and clients. Rony makes it easy. Rony internally uses Raft for consensuses
However, to develop your service using Rony framework, there are more works to initialize your code comparing to other RESTful frameworks. To help you setup the skeleton even faster there is an executable to makes the life easier for you.

Installation

Use go get to install the Go client-and-server generator:

go get -u github.com/ronaksoft/rony/cmd/rony
go get -u github.com/ronaksoft/rony/cmd/protoc-gen-rony

You will also need:

  • protoc, the protobuf compiler. You need version 3+.
  • github.com/golang/protobuf/protoc-gen-go, the Go protobuf generator plugin. Get this with go get
Getting Started

After we have installed two executable files protoc-gen-rony and rony you are ready to create your project.

mkdir sample-project
cd ./sample-project
rony project create --project.name github.com/ronaksoft/sample --project.name sample-project

After running the 'project create' command, you should go to the service directory and open service.proto file and write the appropriate protobuf file. You can also go to model directory and edit the model.proto file, but it is an advanced topic. we just delete it. After finishing our edit job we run the following command from the root of our project.

rony project gen-proto

The above command generates the boiler plate codes for our service.

Features
  1. Gossip Protocol
  2. Raft
  3. ProtocolBuffer friendly rpc
  4. Multiple gateways: Websocket, Http, Quic

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() {
	server := edge.NewServer(serverID,
		edge.WithDispatcher(&dispatcher{}),
		edge.WithTcpGateway(edge.TcpGatewayConfig{
			Concurrency:   1000,
			MaxIdleTime:   0,
			ListenAddress: "0.0.0.0:80",
			ExternalAddr:  []string{"127.0.0.1:80"}, // ExternalAddr could be used when the server is behind proxy or nats
		}),
		edge.WithUdpTunnel(edge.UdpTunnelConfig{
			ServerID:      serverID,
			Concurrency:   1000,
			ListenAddress: "0.0.0.0:8080",
			MaxBodySize:   0,
			ExternalAddrs: nil,
		}),
		edge.WithGossipCluster(edge.GossipClusterConfig{
			ServerID:   serverID,
			Bootstrap:  true,
			RaftPort:   7090,
			ReplicaSet: 1,
			Mode:       cluster.MultiReplica,
			GossipPort: 7091,
			DataPath:   "./data",
		}),
	)

	server.AddHandler(msg.C_EchoRequest, EchoHandler)

	server.Start()
	
	server.ShutdownWithSignal(os.Kill)
}

func EchoHandler(ctx *context.Context, in *msg.MessageEnvelope) {
	req := msg.EchoRequest{}
	res := msg.EchoResponse{}
	_ = req.Unmarshal(in.Message)

	res.Bool = req.Bool
	res.Int = req.Int
	res.Timestamp = time.Now().UnixNano()
	res.Delay = res.Timestamp - req.Timestamp

	ctx.PushMessage(ctx.AuthID, in.RequestID, msg.C_EchoResponse, res)
}

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

Redirect Handling
Code Generators

You must install the following protoc plugins which generate the appropriate codes

  1. protoc-gen-gorony
go get -u github.com/ronaksoft/rony/cmd/protoc-gen-gorony

This is a protoc pluging which could generate codes based on the protobuf. In addition to
protobuffer syntax there are directive commands available which let the user generate more
customized code. 


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
  • Model Descriptor implementation for:
    1. Scylla
    2. MongoDB
    3. Redis
    4. Aerospike
  • Middleware support for server side rpc handlers
  • Update documentation
  • Improve test coverage
  • Support Actor model for communication between nodes
  • CLI client generator, make testing server scenarios handy

Documentation

Index

Constants

View Source
const (
	ErrCodeInternal         = "E00" // When Error is Unknown or it is internal and should not be exposed to the client
	ErrCodeInvalid          = "E01"
	ErrCodeUnavailable      = "E02"
	ErrCodeTooMany          = "E03"
	ErrCodeTooFew           = "E04"
	ErrCodeIncomplete       = "E05"
	ErrCodeTimeout          = "E06"
	ErrCodeAccess           = "E07"
	ErrCodeAlreadyExists    = "E08"
	ErrCodeBusy             = "E09"
	ErrCodeOutOfRange       = "E10"
	ErrCodePartiallyApplied = "E11"
	ErrCodeExpired          = "E12"
	ErrCodeNotImplemented   = "E13"
)

Error Codes

View Source
const (
	ErrItemServer     = "SERVER"
	ErrItemRaftLeader = "RAFT_LEADER"
	ErrItemHandler    = "HANDLER"
	ErrItemRequest    = "REQUEST"
)

Error Items

View Source
const C_Edge int64 = 3576986712
View Source
const C_EdgeNode int64 = 999040174
View Source
const C_Edges int64 = 2120950449
View Source
const C_Error int64 = 2619118453
View Source
const C_GetNodes int64 = 362407405
View Source
const C_GetPage int64 = 3721890413
View Source
const C_KeyValue int64 = 4276272820
View Source
const C_MessageContainer int64 = 1972016308
View Source
const C_MessageEnvelope int64 = 535232465
View Source
const C_Page int64 = 3023575326
View Source
const C_RaftCommand int64 = 2919813429
View Source
const C_Redirect int64 = 981138557
View Source
const C_TunnelMessage int64 = 3271476222

Variables

View Source
var (
	ErrGatewayAlreadyInitialized = errors.New("gateway already initialized")
	ErrNotFound                  = errors.New("not found")
	ErrAlreadyExists             = errors.New("already exists")
	ErrNotRaftLeader             = errors.New("not raft leader")
	ErrRaftAlreadyJoined         = errors.New("raft already joined")
	ErrRaftExecuteOnLeader       = errors.New("raft execute on leader")
	ErrRetriesExceeded           = wrapError("maximum retries exceeded")
)

Errors

View Source
var (
	RaftState_name = map[int32]string{
		0: "None",
		1: "Follower",
		2: "Candidate",
		3: "Leader",
		4: "Shutdown",
	}
	RaftState_value = map[string]int32{
		"None":      0,
		"Follower":  1,
		"Candidate": 2,
		"Leader":    3,
		"Shutdown":  4,
	}
)

Enum value maps for RaftState.

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

Enum value maps for RedirectReason.

View Source
var (
	// rony_cobra_cmd generates the boiler plate code for client stub of rpc methods, using cobra package.
	//
	// optional bool rony_cobra_cmd = 50001;
	E_RonyCobraCmd = &file_options_proto_extTypes[0]
	// rony_cobra_cmd_protocol defines what protocol should client use to communicate with server.
	// POSSIBLE VALUES: "ws", "http"
	//
	// optional string rony_cobra_cmd_protocol = 50002;
	E_RonyCobraCmdProtocol = &file_options_proto_extTypes[1]
	// 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[2]
)

Extension fields to descriptorpb.ServiceOptions.

View Source
var (
	// rony_inconsistent_read marks this method that it could be called on nodes with FOLLOWER state. Otherwise methods could only
	// be executed on LEADER nodes.
	//
	// optional bool rony_inconsistent_read = 50001;
	E_RonyInconsistentRead = &file_options_proto_extTypes[3]
	// 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[4]
)

Extension fields to descriptorpb.MethodOptions.

View Source
var (
	// rony_aggregate marks this message as an aggregate, then 'rony_table' and 'rony_view' options become available for this
	// message.
	//
	// optional bool rony_aggregate = 50001;
	E_RonyAggregate = &file_options_proto_extTypes[5]
	// rony_singleton marks this message as a singleton.
	// NOTE: a message could either have 'rony_aggregate' ro 'rony_singleton' options at a same time. Setting both
	// cause unpredictable results.
	//
	// optional bool rony_singleton = 50002;
	E_RonySingleton = &file_options_proto_extTypes[6]
	// rony_aggregate_type makes the code generator to generate appropriate functions based on the way you are going
	// to handle actions on the aggregate.
	// POSSIBLE_VALUES: "crud", "eventsource"
	//
	// optional string rony_aggregate_type = 50010;
	E_RonyAggregateType = &file_options_proto_extTypes[7]
	// rony_aggregate_command makes this message as a command which is ONLY used if rony_aggregate_type is set to 'eventsource'.
	// If this option is set then you MUST also define rony_aggregate_link to identify which aggregate this command will work on.
	//
	// optional bool rony_aggregate_command = 50011;
	E_RonyAggregateCommand = &file_options_proto_extTypes[8]
	// rony_aggregate_event makes this message as an event which is ONLY used if rony_aggregate_type is set to 'eventsource'
	// If this option is set then you MUST also define rony_aggregate_link to identify which aggregate this event will be read from.
	//
	// optional bool rony_aggregate_event = 50012;
	E_RonyAggregateEvent = &file_options_proto_extTypes[9]
	// rony_aggregate_link is the name of the aggregate message which we link this message to.
	//
	// optional string rony_aggregate_link = 50013;
	E_RonyAggregateLink = &file_options_proto_extTypes[10]
	// rony_aggregate_table creates a virtual table presentation to hold instances of this message, like rows in a table
	// PRIMARY KEY FORMAT: ( (partitionKey1, partitionKey2, ...), clusteringKey1, clusteringKey2, ...)
	// NOTE: If there is only one partition key then you could safely drop the parenthesis, i.e. (pk1, ck1, ck2)
	//
	// optional string rony_aggregate_table = 50014;
	E_RonyAggregateTable = &file_options_proto_extTypes[11]
	// rony_aggregate_view creates a materialized view of the aggregate based on the primary key.
	// PRIMARY KEY FORMAT: ( (partitionKey1, partitionKey2, ...), clusteringKey1, clusteringKey2, ...)
	// NOTE (1): If there is only one partition key then you could safely drop the parenthesis, i.e. (pk1, ck1, ck2)
	// NOTE (2): The primary key of the model 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:
	//                  rony_aggregate_table = ((a, b), c)
	//                  rony_aggregate_view = ((c, a), d, b)
	//
	// optional string rony_aggregate_view = 50015;
	E_RonyAggregateView = &file_options_proto_extTypes[12]
)

Extension fields to descriptorpb.MessageOptions.

View Source
var (
	// optional bool rony_index = 50001;
	E_RonyIndex = &file_options_proto_extTypes[13]
)

Extension fields to descriptorpb.FieldOptions.

View Source
var File_options_proto protoreflect.FileDescriptor
View Source
var PoolEdge = poolEdge{}
View Source
var PoolEdgeNode = poolEdgeNode{}
View Source
var PoolEdges = poolEdges{}
View Source
var PoolError = poolError{}
View Source
var PoolGetNodes = poolGetNodes{}
View Source
var PoolGetPage = poolGetPage{}
View Source
var PoolKeyValue = poolKeyValue{}
View Source
var PoolMessageContainer = poolMessageContainer{}
View Source
var PoolMessageEnvelope = poolMessageEnvelope{}
View Source
var PoolPage = poolPage{}
View Source
var PoolRaftCommand = poolRaftCommand{}
View Source
var PoolRedirect = poolRedirect{}
View Source
var PoolTunnelMessage = poolTunnelMessage{}

Functions

func ConstructorOf

func ConstructorOf(x interface{}) int64

ConstructorOf

func CreatePage added in v0.5.25

func CreatePage(m *Page) error

func CreatePageWithTxn added in v0.5.25

func CreatePageWithTxn(txn *store.Txn, alloc *store.Allocator, m *Page) (err error)

func DeletePage added in v0.5.0

func DeletePage(id uint32) error

func DeletePageWithTxn added in v0.5.0

func DeletePageWithTxn(txn *store.Txn, alloc *store.Allocator, id uint32) error

func ErrorMessage

func ErrorMessage(out *MessageEnvelope, reqID uint64, errCode, errItem string)

func IterPageByReplicaSet added in v0.5.0

func IterPageByReplicaSet(txn *store.Txn, alloc *store.Allocator, replicaSet uint64, cb func(m *Page) bool) error

func IterPages added in v0.5.0

func IterPages(txn *store.Txn, alloc *store.Allocator, cb func(m *Page) bool) error

func RegisterPrometheus added in v0.5.8

func RegisterPrometheus(registerer prometheus.Registerer)

RegisterPrometheus

func SavePage added in v0.5.0

func SavePage(m *Page) error

func SavePageWithTxn added in v0.5.0

func SavePageWithTxn(txn *store.Txn, alloc *store.Allocator, m *Page) (err error)

func SetLogLevel

func SetLogLevel(l int)

SetLogLevel is used for debugging purpose -1 : DEBUG 0 : INFO 1 : WARN 2 : ERROR

func UpdatePage added in v0.5.25

func UpdatePage(id uint32, m *Page) error

func UpdatePageWithTxn added in v0.5.25

func UpdatePageWithTxn(txn *store.Txn, alloc *store.Allocator, m *Page) error

Types

type Conn added in v0.1.9

type Conn interface {
	ConnID() uint64
	ClientIP() string
	SendBinary(streamID int64, data []byte) error
	Persistent() bool
	Get(key string) interface{}
	Set(key string, val interface{})
}

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"`
	Leader     bool     `protobuf:"varint,4,opt,name=Leader,proto3" json:"Leader,omitempty"`
	// contains filtered or unexported fields
}

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) GetLeader added in v0.5.0

func (x *Edge) GetLeader() bool

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) 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

type EdgeNode

type EdgeNode struct {
	ServerID    []byte    `protobuf:"bytes,1,opt,name=ServerID,proto3" json:"ServerID,omitempty"`
	ReplicaSet  uint64    `protobuf:"varint,2,opt,name=ReplicaSet,proto3" json:"ReplicaSet,omitempty"`
	RaftPort    uint32    `protobuf:"varint,5,opt,name=RaftPort,proto3" json:"RaftPort,omitempty"`
	RaftState   RaftState `protobuf:"varint,6,opt,name=RaftState,proto3,enum=rony.RaftState" json:"RaftState,omitempty"`
	GatewayAddr []string  `protobuf:"bytes,7,rep,name=GatewayAddr,proto3" json:"GatewayAddr,omitempty"`
	TunnelAddr  []string  `protobuf:"bytes,8,rep,name=TunnelAddr,proto3" json:"TunnelAddr,omitempty"`
	// contains filtered or unexported fields
}

EdgeNode

func (*EdgeNode) DeepCopy

func (x *EdgeNode) DeepCopy(z *EdgeNode)

func (*EdgeNode) Descriptor deprecated

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

Deprecated: Use EdgeNode.ProtoReflect.Descriptor instead.

func (*EdgeNode) GetGatewayAddr

func (x *EdgeNode) GetGatewayAddr() []string

func (*EdgeNode) GetRaftPort

func (x *EdgeNode) GetRaftPort() uint32

func (*EdgeNode) GetRaftState

func (x *EdgeNode) GetRaftState() RaftState

func (*EdgeNode) GetReplicaSet

func (x *EdgeNode) GetReplicaSet() uint64

func (*EdgeNode) GetServerID

func (x *EdgeNode) GetServerID() []byte

func (*EdgeNode) GetTunnelAddr added in v0.1.8

func (x *EdgeNode) GetTunnelAddr() []string

func (*EdgeNode) Marshal added in v0.0.17

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

func (*EdgeNode) ProtoMessage

func (*EdgeNode) ProtoMessage()

func (*EdgeNode) ProtoReflect

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

func (*EdgeNode) Reset

func (x *EdgeNode) Reset()

func (*EdgeNode) String

func (x *EdgeNode) String() string

func (*EdgeNode) Unmarshal

func (x *EdgeNode) Unmarshal(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) 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) 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

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) 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

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) 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) Unmarshal

func (x *Error) Unmarshal(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) 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) 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

type GetPage added in v0.5.0

type GetPage struct {
	PageID     uint32 `protobuf:"varint,1,opt,name=PageID,proto3" json:"PageID,omitempty"`
	ReplicaSet uint64 `protobuf:"varint,2,opt,name=ReplicaSet,proto3" json:"ReplicaSet,omitempty"`
	// contains filtered or unexported fields
}

GetPage @Function @Return: Page

func (*GetPage) DeepCopy added in v0.5.0

func (x *GetPage) DeepCopy(z *GetPage)

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

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

Deprecated: Use GetPage.ProtoReflect.Descriptor instead.

func (*GetPage) GetPageID added in v0.5.0

func (x *GetPage) GetPageID() uint32

func (*GetPage) GetReplicaSet added in v0.5.0

func (x *GetPage) GetReplicaSet() uint64

func (*GetPage) Marshal added in v0.5.0

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

func (*GetPage) ProtoMessage added in v0.5.0

func (*GetPage) ProtoMessage()

func (*GetPage) ProtoReflect added in v0.5.0

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

func (*GetPage) Reset added in v0.5.0

func (x *GetPage) Reset()

func (*GetPage) String added in v0.5.0

func (x *GetPage) String() string

func (*GetPage) Unmarshal added in v0.5.0

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

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) 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) 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

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"`
	// contains filtered or unexported fields
}

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

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) Marshal added in v0.0.17

func (x *MessageContainer) Marshal() ([]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

type MessageEnvelope

type MessageEnvelope struct {
	Constructor int64       `protobuf:"varint,1,opt,name=Constructor,proto3" json:"Constructor,omitempty"`
	RequestID   uint64      `protobuf:"fixed64,2,opt,name=RequestID,proto3" json:"RequestID,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) 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 int64, 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() int64

func (*MessageEnvelope) GetHeader

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

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) 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

type Page added in v0.5.0

type Page struct {
	ID         uint32 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
	ReplicaSet uint64 `protobuf:"varint,2,opt,name=ReplicaSet,proto3" json:"ReplicaSet,omitempty"`
	// contains filtered or unexported fields
}

Page

func ListPage added in v0.5.0

func ListPage(
	offsetID uint32, lo *store.ListOption, cond func(m *Page) bool,
) ([]*Page, error)

func ListPageByReplicaSet added in v0.5.0

func ListPageByReplicaSet(replicaSet uint64, offsetID uint32, lo *store.ListOption) ([]*Page, error)

func ReadPage added in v0.5.0

func ReadPage(id uint32, m *Page) (*Page, error)

func ReadPageByReplicaSetAndID added in v0.5.0

func ReadPageByReplicaSetAndID(replicaSet uint64, id uint32, m *Page) (*Page, error)

func ReadPageByReplicaSetAndIDWithTxn added in v0.5.0

func ReadPageByReplicaSetAndIDWithTxn(txn *store.Txn, alloc *store.Allocator, replicaSet uint64, id uint32, m *Page) (*Page, error)

func ReadPageWithTxn added in v0.5.0

func ReadPageWithTxn(txn *store.Txn, alloc *store.Allocator, id uint32, m *Page) (*Page, error)

func (*Page) DeepCopy added in v0.5.0

func (x *Page) DeepCopy(z *Page)

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

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

Deprecated: Use Page.ProtoReflect.Descriptor instead.

func (*Page) GetID added in v0.5.0

func (x *Page) GetID() uint32

func (*Page) GetReplicaSet added in v0.5.0

func (x *Page) GetReplicaSet() uint64

func (*Page) Marshal added in v0.5.0

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

func (*Page) ProtoMessage added in v0.5.0

func (*Page) ProtoMessage()

func (*Page) ProtoReflect added in v0.5.0

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

func (*Page) Reset added in v0.5.0

func (x *Page) Reset()

func (*Page) String added in v0.5.0

func (x *Page) String() string

func (*Page) Unmarshal added in v0.5.0

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

type RaftCommand

type RaftCommand struct {
	Sender   []byte           `protobuf:"bytes,1,opt,name=Sender,proto3" json:"Sender,omitempty"`
	Store    []*KeyValue      `protobuf:"bytes,2,rep,name=Store,proto3" json:"Store,omitempty"`
	Envelope *MessageEnvelope `protobuf:"bytes,3,opt,name=Envelope,proto3" json:"Envelope,omitempty"`
	// contains filtered or unexported fields
}

RaftCommand

func (*RaftCommand) DeepCopy

func (x *RaftCommand) DeepCopy(z *RaftCommand)

func (*RaftCommand) Descriptor deprecated

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

Deprecated: Use RaftCommand.ProtoReflect.Descriptor instead.

func (*RaftCommand) Fill

func (x *RaftCommand) Fill(senderID []byte, e *MessageEnvelope, kvs ...*KeyValue)

func (*RaftCommand) GetEnvelope

func (x *RaftCommand) GetEnvelope() *MessageEnvelope

func (*RaftCommand) GetSender

func (x *RaftCommand) GetSender() []byte

func (*RaftCommand) GetStore

func (x *RaftCommand) GetStore() []*KeyValue

func (*RaftCommand) Marshal added in v0.0.17

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

func (*RaftCommand) ProtoMessage

func (*RaftCommand) ProtoMessage()

func (*RaftCommand) ProtoReflect

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

func (*RaftCommand) Reset

func (x *RaftCommand) Reset()

func (*RaftCommand) String

func (x *RaftCommand) String() string

func (*RaftCommand) Unmarshal

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

type RaftState

type RaftState int32

RaftState

const (
	RaftState_None      RaftState = 0
	RaftState_Follower  RaftState = 1
	RaftState_Candidate RaftState = 2
	RaftState_Leader    RaftState = 3
	RaftState_Shutdown  RaftState = 4
)

func (RaftState) Descriptor

func (RaftState) Descriptor() protoreflect.EnumDescriptor

func (RaftState) Enum

func (x RaftState) Enum() *RaftState

func (RaftState) EnumDescriptor deprecated

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

Deprecated: Use RaftState.Descriptor instead.

func (RaftState) Number

func (x RaftState) Number() protoreflect.EnumNumber

func (RaftState) String

func (x RaftState) String() string

func (RaftState) Type

type Redirect

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

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) GetFollowers added in v0.1.5

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

func (*Redirect) GetLeader added in v0.1.5

func (x *Redirect) GetLeader() *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) 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

type RedirectReason added in v0.1.5

type RedirectReason int32

RedirectReason

const (
	RedirectReason_ReplicaMaster     RedirectReason = 0
	RedirectReason_ReplicaSetSession RedirectReason = 1
	RedirectReason_ReplicaSetRequest RedirectReason = 2
	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 TunnelMessage added in v0.1.8

type TunnelMessage struct {
	SenderID         []byte           `protobuf:"bytes,1,opt,name=SenderID,proto3" json:"SenderID,omitempty"`
	SenderReplicaSet uint64           `protobuf:"varint,2,opt,name=SenderReplicaSet,proto3" json:"SenderReplicaSet,omitempty"`
	Store            []*KeyValue      `protobuf:"bytes,3,rep,name=Store,proto3" json:"Store,omitempty"`
	Envelope         *MessageEnvelope `protobuf:"bytes,4,opt,name=Envelope,proto3" json:"Envelope,omitempty"`
	// contains filtered or unexported fields
}

TunnelMessage

func (*TunnelMessage) DeepCopy added in v0.1.8

func (x *TunnelMessage) DeepCopy(z *TunnelMessage)

func (*TunnelMessage) Descriptor deprecated added in v0.1.8

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

Deprecated: Use TunnelMessage.ProtoReflect.Descriptor instead.

func (*TunnelMessage) Fill added in v0.1.8

func (x *TunnelMessage) Fill(senderID []byte, senderReplicaSet uint64, e *MessageEnvelope, kvs ...*KeyValue)

func (*TunnelMessage) GetEnvelope added in v0.1.8

func (x *TunnelMessage) GetEnvelope() *MessageEnvelope

func (*TunnelMessage) GetSenderID added in v0.1.8

func (x *TunnelMessage) GetSenderID() []byte

func (*TunnelMessage) GetSenderReplicaSet added in v0.1.8

func (x *TunnelMessage) GetSenderReplicaSet() uint64

func (*TunnelMessage) GetStore added in v0.1.8

func (x *TunnelMessage) GetStore() []*KeyValue

func (*TunnelMessage) Marshal added in v0.1.8

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

func (*TunnelMessage) ProtoMessage added in v0.1.8

func (*TunnelMessage) ProtoMessage()

func (*TunnelMessage) ProtoReflect added in v0.1.8

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

func (*TunnelMessage) Reset added in v0.1.8

func (x *TunnelMessage) Reset()

func (*TunnelMessage) String added in v0.1.8

func (x *TunnelMessage) String() string

func (*TunnelMessage) Unmarshal added in v0.1.8

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

Directories

Path Synopsis
cmd
internal
gateway/tcp/util
Package wsutil provides utilities for working with WebSocket protocol.
Package wsutil provides utilities for working with WebSocket protocol.
log
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.

Jump to

Keyboard shortcuts

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