Documentation ¶
Index ¶
- func NewRestProxy(onClientMessage, onServerMessage RestHandler) *restProxy
- type Builtin
- type DispatchCtx
- func (ctx *DispatchCtx) BufferPop(f func(envelope *rony.MessageEnvelope)) bool
- func (ctx *DispatchCtx) BufferPopAll(f func(envelope *rony.MessageEnvelope))
- func (ctx *DispatchCtx) BufferPush(m *rony.MessageEnvelope)
- func (ctx *DispatchCtx) BufferSize() int32
- func (ctx *DispatchCtx) Conn() rony.Conn
- func (ctx *DispatchCtx) Debug()
- func (ctx *DispatchCtx) Fill(requestID uint64, constructor uint64, p proto.Message, kv ...*rony.KeyValue)
- func (ctx *DispatchCtx) FillBytes(data []byte) error
- func (ctx *DispatchCtx) FillEnvelope(e *rony.MessageEnvelope)
- func (ctx *DispatchCtx) Get(key string) interface{}
- func (ctx *DispatchCtx) GetBool(key string) bool
- func (ctx *DispatchCtx) GetBytes(key string, defaultValue []byte) []byte
- func (ctx *DispatchCtx) GetInt64(key string, defaultValue int64) int64
- func (ctx *DispatchCtx) GetString(key string, defaultValue string) string
- func (ctx *DispatchCtx) Kind() MessageKind
- func (ctx *DispatchCtx) ServerID() string
- func (ctx *DispatchCtx) Set(key string, v interface{})
- func (ctx *DispatchCtx) StreamID() int64
- type Dispatcher
- type DummyGatewayConfig
- type GossipClusterConfig
- type Handler
- type HandlerOption
- func (ho *HandlerOption) Append(h ...Handler) *HandlerOption
- func (ho *HandlerOption) GatewayOnly() *HandlerOption
- func (ho *HandlerOption) Prepend(h ...Handler) *HandlerOption
- func (ho *HandlerOption) SetConstructor(constructors ...uint64) *HandlerOption
- func (ho *HandlerOption) SetHandler(h ...Handler) *HandlerOption
- func (ho *HandlerOption) SetMethodName(methodName string) *HandlerOption
- func (ho *HandlerOption) SetServiceName(serviceName string) *HandlerOption
- func (ho *HandlerOption) TunnelOnly() *HandlerOption
- type InsertOption
- type MessageKind
- type Option
- func WithCustomDispatcher(d Dispatcher) Option
- func WithCustomGateway(gateway rony.Gateway) Option
- func WithCustomRouter(r rony.Router) Option
- func WithCustomerCluster(c rony.Cluster) Option
- func WithGossipCluster(clusterConfig GossipClusterConfig) Option
- func WithScyllaRouter(config ScyllaRouterConfig) Option
- func WithSqlRouter(config SqlRouterConfig) Option
- func WithTcpGateway(gatewayConfig TcpGatewayConfig) Option
- func WithTestGateway(gatewayConfig DummyGatewayConfig) Option
- func WithTracer(tracer trace.Tracer) Option
- func WithUdpTunnel(config UdpTunnelConfig) Option
- type ParamsSetter
- type RequestCtx
- func (ctx *RequestCtx) Cluster() rony.Cluster
- func (ctx *RequestCtx) ClusterEdges(replicaSet uint64, edges *rony.Edges) (*rony.Edges, error)
- func (ctx *RequestCtx) Conn() rony.Conn
- func (ctx *RequestCtx) ConnID() uint64
- func (ctx *RequestCtx) Context() context.Context
- func (ctx *RequestCtx) Error() *rony.Error
- func (ctx *RequestCtx) Get(key string) interface{}
- func (ctx *RequestCtx) GetBool(key string) bool
- func (ctx *RequestCtx) GetBytes(key string, defaultValue []byte) []byte
- func (ctx *RequestCtx) GetInt64(key string, defaultValue int64) int64
- func (ctx *RequestCtx) GetString(key string, defaultValue string) string
- func (ctx *RequestCtx) Kind() MessageKind
- func (ctx *RequestCtx) Log() log.Logger
- func (ctx *RequestCtx) NextCanGo()
- func (ctx *RequestCtx) PushCustomError(code, item string, desc string)
- func (ctx *RequestCtx) PushCustomMessage(requestID uint64, constructor uint64, message proto.Message, ...)
- func (ctx *RequestCtx) PushError(err *rony.Error)
- func (ctx *RequestCtx) PushMessage(constructor uint64, proto proto.Message)
- func (ctx *RequestCtx) PushRedirectRequest(replicaSet uint64)
- func (ctx *RequestCtx) PushRedirectSession(replicaSet uint64)
- func (ctx *RequestCtx) ReplicaSet() uint64
- func (ctx *RequestCtx) ReqID() uint64
- func (ctx *RequestCtx) Router() rony.Router
- func (ctx *RequestCtx) ServerID() string
- func (ctx *RequestCtx) Set(key string, v interface{})
- func (ctx *RequestCtx) Span() trace.Span
- func (ctx *RequestCtx) StopExecution()
- func (ctx *RequestCtx) Stopped() bool
- func (ctx *RequestCtx) TryTunnelRequest(attempts int, retryWait time.Duration, replicaSet uint64, ...) error
- func (ctx *RequestCtx) TunnelRequest(replicaSet uint64, req, res *rony.MessageEnvelope) error
- type RestHandler
- type RestProxy
- type ScyllaRouterConfig
- type Server
- func (edge *Server) Cluster() rony.Cluster
- func (edge *Server) Gateway() rony.Gateway
- func (edge *Server) GetGatewayConn(connID uint64) rony.Conn
- func (edge *Server) GetHandler(constructor uint64) *HandlerOption
- func (edge *Server) GetServerID() string
- func (edge *Server) SetCustomDispatcher(d Dispatcher)
- func (edge *Server) SetGlobalPostHandlers(handlers ...Handler)
- func (edge *Server) SetGlobalPreHandlers(handlers ...Handler)
- func (edge *Server) SetHandler(ho *HandlerOption)
- func (edge *Server) SetRestProxy(method string, path string, p RestProxy)
- func (edge *Server) Shutdown()
- func (edge *Server) ShutdownWithSignal(signals ...os.Signal) error
- func (edge *Server) Start()
- func (edge *Server) StartCluster() (err error)
- func (edge *Server) StartGateway() error
- func (edge *Server) StartTunnel() error
- func (edge *Server) Stats() Stats
- func (edge *Server) TryTunnelRequest(attempts int, retryWait time.Duration, replicaSet uint64, ...) error
- func (edge *Server) Tunnel() rony.Tunnel
- func (edge *Server) TunnelRequest(replicaSet uint64, req, res *rony.MessageEnvelope) error
- func (edge *Server) WaitForSignal(signals ...os.Signal)
- type SqlRouterConfig
- type Stats
- type TcpGatewayConfig
- type UdpTunnelConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRestProxy ¶ added in v0.10.0
func NewRestProxy(onClientMessage, onServerMessage RestHandler) *restProxy
Types ¶
type Builtin ¶ added in v0.5.0
type Builtin struct {
// contains filtered or unexported fields
}
Builtin keep track of pages distribution over Edge servers.
type DispatchCtx ¶
type DispatchCtx struct {
// contains filtered or unexported fields
}
DispatchCtx holds the context of the dispatcher's request. Each DispatchCtx could hold one or many RequestCtx. DispatchCtx lives until the last of its RequestCtx children.
func (*DispatchCtx) BufferPop ¶ added in v0.1.9
func (ctx *DispatchCtx) BufferPop(f func(envelope *rony.MessageEnvelope)) bool
func (*DispatchCtx) BufferPopAll ¶ added in v0.10.0
func (ctx *DispatchCtx) BufferPopAll(f func(envelope *rony.MessageEnvelope))
func (*DispatchCtx) BufferPush ¶ added in v0.1.9
func (ctx *DispatchCtx) BufferPush(m *rony.MessageEnvelope)
func (*DispatchCtx) BufferSize ¶ added in v0.1.9
func (ctx *DispatchCtx) BufferSize() int32
func (*DispatchCtx) Conn ¶
func (ctx *DispatchCtx) Conn() rony.Conn
func (*DispatchCtx) Debug ¶
func (ctx *DispatchCtx) Debug()
func (*DispatchCtx) FillBytes ¶ added in v0.14.1
func (ctx *DispatchCtx) FillBytes(data []byte) error
func (*DispatchCtx) FillEnvelope ¶
func (ctx *DispatchCtx) FillEnvelope(e *rony.MessageEnvelope)
func (*DispatchCtx) Get ¶
func (ctx *DispatchCtx) Get(key string) interface{}
func (*DispatchCtx) GetBool ¶
func (ctx *DispatchCtx) GetBool(key string) bool
func (*DispatchCtx) GetBytes ¶
func (ctx *DispatchCtx) GetBytes(key string, defaultValue []byte) []byte
func (*DispatchCtx) GetInt64 ¶
func (ctx *DispatchCtx) GetInt64(key string, defaultValue int64) int64
func (*DispatchCtx) GetString ¶
func (ctx *DispatchCtx) GetString(key string, defaultValue string) string
func (*DispatchCtx) Kind ¶ added in v0.1.4
func (ctx *DispatchCtx) Kind() MessageKind
Kind identifies that this dispatch context is generated from Tunnel or Gateway. This helps developer to apply different strategies based on the source of the incoming message
func (*DispatchCtx) ServerID ¶ added in v0.1.9
func (ctx *DispatchCtx) ServerID() string
func (*DispatchCtx) Set ¶
func (ctx *DispatchCtx) Set(key string, v interface{})
func (*DispatchCtx) StreamID ¶
func (ctx *DispatchCtx) StreamID() int64
type Dispatcher ¶
type Dispatcher interface { // OnMessage is called on every message pushed to RequestCtx. // All the input arguments are valid in the function context, if you need to pass 'envelope' to other // async functions, make sure to hard copy (clone) it before sending it. // **NOTE**: This is not called on non-persistent connections, instead it is user's responsibility to check the // ctx.BufferSize() and ctx.BufferPop() functions OnMessage(ctx *DispatchCtx, envelope *rony.MessageEnvelope) // Interceptor is called before any handler called. // All the input arguments are valid in the function context, if you need to pass 'data' or 'envelope' to other // async functions, make sure to hard copy (clone) it before sending it. If 'err' is not nil then envelope will be // discarded, it is the user's responsibility to send back appropriate message using 'conn' // Note that conn IS NOT nil in any circumstances. Interceptor(ctx *DispatchCtx, data []byte) (err error) // Done will be called when the context has been finished, this lets cleaning up, or in case you need to flush the // messages and updates in one go. Done(ctx *DispatchCtx) // OnOpen will be called when a new connection has been opened OnOpen(conn rony.Conn, kvs ...*rony.KeyValue) // OnClose will be called when a connection is closed OnClose(conn rony.Conn) }
type DummyGatewayConfig ¶ added in v0.1.8
type DummyGatewayConfig = dummyGateway.Config
type GossipClusterConfig ¶ added in v0.1.8
type Handler ¶
type Handler = func(ctx *RequestCtx, in *rony.MessageEnvelope)
type HandlerOption ¶ added in v0.5.7
type HandlerOption struct {
// contains filtered or unexported fields
}
HandlerOption is a structure holds all the information required for a handler.
func NewHandlerOptions ¶ added in v0.3.12
func NewHandlerOptions() *HandlerOption
func (*HandlerOption) Append ¶ added in v0.5.7
func (ho *HandlerOption) Append(h ...Handler) *HandlerOption
Append adds the h handlers after already set handlers
func (*HandlerOption) GatewayOnly ¶ added in v0.5.7
func (ho *HandlerOption) GatewayOnly() *HandlerOption
GatewayOnly makes this method only available through gateway messages.
func (*HandlerOption) Prepend ¶ added in v0.5.7
func (ho *HandlerOption) Prepend(h ...Handler) *HandlerOption
Prepend adds the h handlers before already set handlers
func (*HandlerOption) SetConstructor ¶ added in v0.6.3
func (ho *HandlerOption) SetConstructor(constructors ...uint64) *HandlerOption
func (*HandlerOption) SetHandler ¶ added in v0.6.3
func (ho *HandlerOption) SetHandler(h ...Handler) *HandlerOption
SetHandler replaces the handlers for this constructor with h
func (*HandlerOption) SetMethodName ¶ added in v0.16.0
func (ho *HandlerOption) SetMethodName(methodName string) *HandlerOption
SetMethodName set the method name for this handler, this is mostly used for Tracing.
func (*HandlerOption) SetServiceName ¶ added in v0.16.0
func (ho *HandlerOption) SetServiceName(serviceName string) *HandlerOption
SetServiceName set the service name for this handler, this is mostly used for Tracing.
func (*HandlerOption) TunnelOnly ¶ added in v0.5.7
func (ho *HandlerOption) TunnelOnly() *HandlerOption
TunnelOnly makes this method only available through tunnel messages.
type InsertOption ¶ added in v0.10.0
type InsertOption func(*trieNode)
InsertOption is just a function which accepts a pointer to a trieNode which can alt its `Handler`, `Tag` and `Data` fields. See `WithHandler`, `WithTag` and `WithData`.
func WithProxyFactory ¶ added in v0.10.0
func WithProxyFactory(proxy RestProxy) InsertOption
WithProxyFactory sets the node's `Handler` field (useful for HTTP).
func WithTag ¶ added in v0.10.0
func WithTag(tag string) InsertOption
WithTag sets the node's `Tag` field (may be useful for HTTP).
type MessageKind ¶ added in v0.5.8
type MessageKind byte
const ( GatewayMessage MessageKind TunnelMessage )
func (MessageKind) String ¶ added in v0.5.8
func (c MessageKind) String() string
type Option ¶
type Option func(edge *Server)
func WithCustomDispatcher ¶ added in v0.14.11
func WithCustomDispatcher(d Dispatcher) Option
WithCustomDispatcher enables custom dispatcher to write your specific event handlers.
func WithCustomGateway ¶ added in v0.16.0
func WithCustomRouter ¶ added in v0.14.1
func WithCustomerCluster ¶ added in v0.14.1
func WithGossipCluster ¶ added in v0.1.5
func WithGossipCluster(clusterConfig GossipClusterConfig) Option
WithGossipCluster enables the cluster in gossip mode. This mod is eventually consistent mode but there is no need to a central key-value store or any other 3rd party service to run the cluster
func WithScyllaRouter ¶ added in v0.14.1
func WithScyllaRouter(config ScyllaRouterConfig) Option
func WithSqlRouter ¶ added in v0.14.6
func WithSqlRouter(config SqlRouterConfig) Option
func WithTcpGateway ¶
func WithTcpGateway(gatewayConfig TcpGatewayConfig) Option
WithTcpGateway set the gateway to tcp which can support http and/or websocket Only one gateway could be set and if you set another gateway it panics on runtime.
func WithTestGateway ¶
func WithTestGateway(gatewayConfig DummyGatewayConfig) Option
WithTestGateway set the gateway to a dummy gateway which is useful for writing tests. Only one gateway could be set and if you set another gateway it panics on runtime.
func WithTracer ¶ added in v0.16.0
func WithUdpTunnel ¶ added in v0.1.8
func WithUdpTunnel(config UdpTunnelConfig) Option
WithUdpTunnel set the tunnel to a udp based tunnel which provides communication channel between edge servers.
type ParamsSetter ¶ added in v0.10.0
type ParamsSetter interface {
Set(string, interface{})
}
ParamsSetter is the interface which should be implemented by the params writer for `search` in order to store the found named path parameters, if any.
type RequestCtx ¶
type RequestCtx struct {
// contains filtered or unexported fields
}
RequestCtx holds the context of an RPC handler
func (*RequestCtx) Cluster ¶ added in v0.2.10
func (ctx *RequestCtx) Cluster() rony.Cluster
func (*RequestCtx) ClusterEdges ¶ added in v0.9.0
func (*RequestCtx) Conn ¶
func (ctx *RequestCtx) Conn() rony.Conn
func (*RequestCtx) ConnID ¶
func (ctx *RequestCtx) ConnID() uint64
func (*RequestCtx) Context ¶ added in v0.16.1
func (ctx *RequestCtx) Context() context.Context
func (*RequestCtx) Error ¶ added in v0.14.30
func (ctx *RequestCtx) Error() *rony.Error
func (*RequestCtx) Get ¶
func (ctx *RequestCtx) Get(key string) interface{}
func (*RequestCtx) GetBool ¶
func (ctx *RequestCtx) GetBool(key string) bool
func (*RequestCtx) GetBytes ¶
func (ctx *RequestCtx) GetBytes(key string, defaultValue []byte) []byte
func (*RequestCtx) GetString ¶
func (ctx *RequestCtx) GetString(key string, defaultValue string) string
func (*RequestCtx) Kind ¶ added in v0.1.4
func (ctx *RequestCtx) Kind() MessageKind
func (*RequestCtx) Log ¶ added in v0.3.18
func (ctx *RequestCtx) Log() log.Logger
Log returns a logger
func (*RequestCtx) NextCanGo ¶ added in v0.14.1
func (ctx *RequestCtx) NextCanGo()
NextCanGo is useful only if the main request is rony.MessageContainer with SyncRun flag set to TRUE. Then by calling this function it lets the next request (if any) executed concurrently.
func (*RequestCtx) PushCustomError ¶
func (ctx *RequestCtx) PushCustomError(code, item string, desc string)
func (*RequestCtx) PushCustomMessage ¶
func (ctx *RequestCtx) PushCustomMessage( requestID uint64, constructor uint64, message proto.Message, kvs ...*rony.KeyValue, )
PushCustomMessage would do different actions based on the Conn. If connection is persistent (i.e. Websocket) then Rony sends the message down to the wire real time. If the connection is not persistent (i.e. HTTP) then Rony push the message into a temporary buffer and at the end of the life-time of the RequestCtx pushes the message as response. If there was multiple message in the buffer then Rony creates a MessageContainer and wrap all those messages in that container. Client needs to unwrap MessageContainer when ever they see it in the response.
func (*RequestCtx) PushError ¶
func (ctx *RequestCtx) PushError(err *rony.Error)
func (*RequestCtx) PushMessage ¶
func (ctx *RequestCtx) PushMessage(constructor uint64, proto proto.Message)
PushMessage is a wrapper func for PushCustomMessage.
func (*RequestCtx) PushRedirectRequest ¶ added in v0.2.10
func (ctx *RequestCtx) PushRedirectRequest(replicaSet uint64)
PushRedirectRequest redirects the client to another server with replicaSet for only this request. This function call StopExecution internally and further handlers would not be called.
func (*RequestCtx) PushRedirectSession ¶ added in v0.2.10
func (ctx *RequestCtx) PushRedirectSession(replicaSet uint64)
PushRedirectSession redirects the client to another server with replicaSet for the rest of the request for this session. The interpretation of session is defined by the application and does not have any side effect on internal states of the Edge server. This function call StopExecution internally and further handlers would not be called.
func (*RequestCtx) ReplicaSet ¶ added in v0.5.7
func (ctx *RequestCtx) ReplicaSet() uint64
func (*RequestCtx) ReqID ¶
func (ctx *RequestCtx) ReqID() uint64
func (*RequestCtx) Router ¶ added in v0.14.1
func (ctx *RequestCtx) Router() rony.Router
func (*RequestCtx) ServerID ¶ added in v0.1.4
func (ctx *RequestCtx) ServerID() string
func (*RequestCtx) Set ¶
func (ctx *RequestCtx) Set(key string, v interface{})
func (*RequestCtx) Span ¶ added in v0.16.0
func (ctx *RequestCtx) Span() trace.Span
Span returns a tracer span. Don't End the span, since it will be closed automatically at the end of RequestCtx lifecycle.
func (*RequestCtx) StopExecution ¶
func (ctx *RequestCtx) StopExecution()
func (*RequestCtx) Stopped ¶
func (ctx *RequestCtx) Stopped() bool
func (*RequestCtx) TryTunnelRequest ¶ added in v0.9.0
func (ctx *RequestCtx) TryTunnelRequest( attempts int, retryWait time.Duration, replicaSet uint64, req, res *rony.MessageEnvelope, ) error
func (*RequestCtx) TunnelRequest ¶ added in v0.9.0
func (ctx *RequestCtx) TunnelRequest(replicaSet uint64, req, res *rony.MessageEnvelope) error
type RestHandler ¶ added in v0.10.0
type RestHandler func(conn rony.RestConn, ctx *DispatchCtx) error
type RestProxy ¶ added in v0.10.0
type RestProxy interface { ClientMessage(conn rony.RestConn, ctx *DispatchCtx) error ServerMessage(conn rony.RestConn, ctx *DispatchCtx) error }
type ScyllaRouterConfig ¶ added in v0.14.1
type ScyllaRouterConfig struct {
DbSession gocqlx.Session
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Cluster ¶ added in v0.3.16
Cluster returns a reference to the underlying cluster of the Edge server
func (*Server) Gateway ¶ added in v0.5.18
Gateway returns a reference to the underlying gateway of the Edge server
func (*Server) GetGatewayConn ¶ added in v0.0.6
GetGatewayConn return the gateway connection identified by connID or returns nil if not found.
func (*Server) GetHandler ¶ added in v0.5.7
func (edge *Server) GetHandler(constructor uint64) *HandlerOption
GetHandler returns the handlers of the constructor
func (*Server) GetServerID ¶
GetServerID return this server id, which MUST be unique in the cluster otherwise the behaviour is unknown.
func (*Server) SetCustomDispatcher ¶ added in v0.14.11
func (edge *Server) SetCustomDispatcher(d Dispatcher)
SetCustomDispatcher replace the default dispatcher with your custom dispatcher. Usually you don't need to use custom dispatcher, but in some rare cases you can implement your own custom dispatcher
func (*Server) SetGlobalPostHandlers ¶ added in v0.3.8
SetGlobalPostHandlers set the handler which will be called after executing any request. These pre handlers are like middlewares which will be automatically triggered for each request. If you want to set post handler for specific request then you must use SetHandlers, PrependHandlers or AppendHandlers
func (*Server) SetGlobalPreHandlers ¶ added in v0.3.8
SetGlobalPreHandlers set the handler which will be called before executing any request. These pre handlers are like middlewares which will be automatically triggered for each request. If you want to set pre handler for specific request then you must use SetHandlers, PrependHandlers or AppendHandlers
func (*Server) SetHandler ¶ added in v0.5.7
func (edge *Server) SetHandler(ho *HandlerOption)
SetHandler set the handlers for the constructor.
func (*Server) SetRestProxy ¶ added in v0.10.0
SetRestProxy set a REST wrapper to expose RPCs in REST (Representational State Transfer) format
func (*Server) ShutdownWithSignal ¶
ShutdownWithSignal blocks until any of the signals has been called
func (*Server) Start ¶ added in v0.1.9
func (edge *Server) Start()
Start is a helper function which tries to start all three parts of the edge server This function does not return any error, if you need to make sure all the parts are started with no error, then you must start each section separately. i.e. use StartGateway, StartCluster and StartTunnel functions.
func (*Server) StartCluster ¶
StartCluster is non-blocking function which runs the cluster component of the Edge server.
func (*Server) StartGateway ¶
StartGateway is non-blocking function runs the gateway in background so we can accept clients requests
func (*Server) StartTunnel ¶ added in v0.1.9
StartTunnel is non-blocking function runs the gateway in background so we can accept other servers requests
func (*Server) TryTunnelRequest ¶ added in v0.9.0
func (*Server) Tunnel ¶ added in v0.9.0
Tunnel returns a reference to the underlying tunnel of the Edge server
func (*Server) TunnelRequest ¶ added in v0.9.0
func (edge *Server) TunnelRequest(replicaSet uint64, req, res *rony.MessageEnvelope) error
TunnelRequest sends and receives a request through the Tunnel interface of the receiver Edge node.
func (*Server) WaitForSignal ¶ added in v0.12.15
type SqlRouterConfig ¶ added in v0.14.6
type Stats ¶
type Stats struct { Address string ReplicaSet uint64 Members int MembershipScore int TunnelAddr []string GatewayProtocol rony.GatewayProtocol GatewayAddr []string }
Stats exports some internal metrics data