Documentation ¶
Index ¶
- Constants
- type Client
- type ClientsMgr
- type Server
- func (s *Server) AddReplica(ctx context.Context, req *middleware.AddReplicaRequest) (*middleware.Empty, error)
- func (s *Server) AddTrigger(ctx context.Context, req *middleware.AddTriggerRequest) (*middleware.Empty, error)
- func (s *Server) AddUser(ctx context.Context, req *middleware.UserRequest) (*middleware.Empty, error)
- func (s *Server) Append(ctx context.Context, req *middleware.AppendRequest) (*middleware.AppendResponse, error)
- func (s *Server) CreateKeygroup(ctx context.Context, req *middleware.CreateKeygroupRequest) (*middleware.Empty, error)
- func (s *Server) Delete(ctx context.Context, req *middleware.DeleteRequest) (*middleware.Empty, error)
- func (s *Server) DeleteKeygroup(ctx context.Context, req *middleware.DeleteKeygroupRequest) (*middleware.Empty, error)
- func (s *Server) GetAllReplica(ctx context.Context, _ *middleware.GetAllReplicaRequest) (*middleware.GetAllReplicaResponse, error)
- func (s *Server) GetKeygroupReplica(ctx context.Context, req *middleware.GetKeygroupReplicaRequest) (*middleware.GetKeygroupReplicaResponse, error)
- func (s *Server) GetKeygroupTriggers(ctx context.Context, req *middleware.GetKeygroupTriggerRequest) (*middleware.GetKeygroupTriggerResponse, error)
- func (s *Server) GetReplica(ctx context.Context, req *middleware.GetReplicaRequest) (*middleware.GetReplicaResponse, error)
- func (s *Server) Notify(_ context.Context, req *middleware.NotifyRequest) (*middleware.NotifyResponse, error)
- func (s *Server) Read(_ context.Context, req *middleware.ReadRequest) (*middleware.ReadResponse, error)
- func (s *Server) RemoveReplica(ctx context.Context, req *middleware.RemoveReplicaRequest) (*middleware.Empty, error)
- func (s *Server) RemoveTrigger(ctx context.Context, req *middleware.RemoveTriggerRequest) (*middleware.Empty, error)
- func (s *Server) RemoveUser(ctx context.Context, req *middleware.UserRequest) (*middleware.Empty, error)
- func (s *Server) Scan(ctx context.Context, req *middleware.ScanRequest) (*middleware.ScanResponse, error)
- func (s *Server) ServeBlocking()
- func (s *Server) Update(ctx context.Context, req *middleware.UpdateRequest) (*middleware.Empty, error)
Constants ¶
const ( // UseSlowerNodeProb In how many percent of the cases: instead of using the fastest client, use a random client to update its readSpeed // only used for Read,Write,Delete,Append (since these are the only operations that update the readSpeed) UseSlowerNodeProb = 0.089 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Client api.ClientClient ReadSpeed float32 // contains filtered or unexported fields }
type ClientsMgr ¶
type ClientsMgr struct { // Mutex for the keygroups map, because it might be changed while iterated over sync.Mutex // contains filtered or unexported fields }
ClientsMgr manages all Clients to Fred that Alexandra has. Is used to get fastest clients to keygroups etc. and to read from anywhere there are 3 variables important for this configuration: keygroupTimeout, otherNodesToAsk, getSlowerNodeProb. Please see their documentation.
type Server ¶
Server listens to GRPC requests from clients (and sends them to the relevant Fred Node etc.) The implementation is split up into different files in this folder.
func NewServer ¶
func NewServer(host string, caCert string, serverCert string, serverKey string, nodesCert string, nodesKey string, lighthouse string, isProxied bool, proxyHost string) *Server
NewServer creates a new Server for requests from Alexandra Clients
func (*Server) AddReplica ¶
func (s *Server) AddReplica(ctx context.Context, req *middleware.AddReplicaRequest) (*middleware.Empty, error)
AddReplica lets the client explicitly add a new replica for a keygroup. In the future, this should happen automatically.
func (*Server) AddTrigger ¶
func (s *Server) AddTrigger(ctx context.Context, req *middleware.AddTriggerRequest) (*middleware.Empty, error)
AddTrigger adds a new trigger to a keygroup.
func (*Server) AddUser ¶
func (s *Server) AddUser(ctx context.Context, req *middleware.UserRequest) (*middleware.Empty, error)
AddUser adds permissions to access a keygroup for a particular user to FReD.
func (*Server) Append ¶
func (s *Server) Append(ctx context.Context, req *middleware.AppendRequest) (*middleware.AppendResponse, error)
Append appends a new datum to an immutable keygroup in FReD. As data cannot be changed, no versions are necessary. Thus, the request is only passed through to FReD without caching it. FReD's append endpoint requires a unique ID for a datum. ALExANDRA automatically uses a Unix nanosecond timestamp for this.
func (*Server) CreateKeygroup ¶
func (s *Server) CreateKeygroup(ctx context.Context, req *middleware.CreateKeygroupRequest) (*middleware.Empty, error)
CreateKeygroup creates the keygroup and also adds the first node (This is two operations in the eye of FReD: CreateKeygroup and AddReplica)
func (*Server) Delete ¶
func (s *Server) Delete(ctx context.Context, req *middleware.DeleteRequest) (*middleware.Empty, error)
Delete deletes a datum in FReD (it is actually only tombstoned, but this is irrelevant to the middleware or client). This could either be a value that has previously been read (if the datum is in cache) or a spontaneous delete.
If write-follows-read (i.e., datum can be found in cache), all versions of that datum are superseded by the write. The assumption is that the client has merged conflicting values.
If spontaneous delete (i.e., datum cannot be found in cache), we assume an empty vector clock in the cache and send that to FReD. If there is a newer (any) data item in FReD already, this will fail.
func (*Server) DeleteKeygroup ¶
func (s *Server) DeleteKeygroup(ctx context.Context, req *middleware.DeleteKeygroupRequest) (*middleware.Empty, error)
DeleteKeygroup deletes a keygroup from FReD.
func (*Server) GetAllReplica ¶
func (s *Server) GetAllReplica(ctx context.Context, _ *middleware.GetAllReplicaRequest) (*middleware.GetAllReplicaResponse, error)
GetAllReplica returns a list of all FReD nodes. In the future, this API will be removed as ALExANDRA handles data // replication.
func (*Server) GetKeygroupReplica ¶
func (s *Server) GetKeygroupReplica(ctx context.Context, req *middleware.GetKeygroupReplicaRequest) (*middleware.GetKeygroupReplicaResponse, error)
GetKeygroupReplica returns a list of all FReD nodes that replicate a given keygroup. In the future, this API will be removed as ALExANDRA handles data replication.
func (*Server) GetKeygroupTriggers ¶
func (s *Server) GetKeygroupTriggers(ctx context.Context, req *middleware.GetKeygroupTriggerRequest) (*middleware.GetKeygroupTriggerResponse, error)
GetKeygroupTriggers returns a list of trigger nodes for a keygroup.
func (*Server) GetReplica ¶
func (s *Server) GetReplica(ctx context.Context, req *middleware.GetReplicaRequest) (*middleware.GetReplicaResponse, error)
GetReplica returns information about a specific FReD node. In the future, this API will be removed as ALExANDRA handles data replication.
func (*Server) Notify ¶ added in v0.2.1
func (s *Server) Notify(_ context.Context, req *middleware.NotifyRequest) (*middleware.NotifyResponse, error)
Notify notifies the middleware about a version of a datum that the client has seen by bypassing the middleware. This is required to capture external causality.
func (*Server) Read ¶
func (s *Server) Read(_ context.Context, req *middleware.ReadRequest) (*middleware.ReadResponse, error)
Read reads a datum from FReD. Read data are placed in cache (if not in there already). If multiple versions of a datum exist, all versions will be returned to the client so that it can choose one. If the read data is outdated compared to seen versions, an error is returned.
func (*Server) RemoveReplica ¶
func (s *Server) RemoveReplica(ctx context.Context, req *middleware.RemoveReplicaRequest) (*middleware.Empty, error)
RemoveReplica lets the client explicitly remove a new replica for a keygroup. In the future, this should happen automatically.
func (*Server) RemoveTrigger ¶
func (s *Server) RemoveTrigger(ctx context.Context, req *middleware.RemoveTriggerRequest) (*middleware.Empty, error)
RemoveTrigger removes a trigger node for a keygroup.
func (*Server) RemoveUser ¶
func (s *Server) RemoveUser(ctx context.Context, req *middleware.UserRequest) (*middleware.Empty, error)
RemoveUser removes permissions to access a keygroup for a particular user from FReD.
func (*Server) Scan ¶
func (s *Server) Scan(ctx context.Context, req *middleware.ScanRequest) (*middleware.ScanResponse, error)
Scan issues a scan request from the client to the middleware. The request is forwarded to FReD and incoming items are checked for their versions by comparing locally cached versions (if any). The local cache is also updated (if applicable).
func (*Server) ServeBlocking ¶
func (s *Server) ServeBlocking()
func (*Server) Update ¶
func (s *Server) Update(ctx context.Context, req *middleware.UpdateRequest) (*middleware.Empty, error)
Update updates a datum in FReD. This could either be a value that has previously been read (if the datum is in cache) or a spontaneous write.
If write-follows-read (i.e., datum can be found in cache), all versions of that datum THAT ARE KNOWN AT THE POINT OF THE UPDATE are superseded by the write. The assumption is that the client has merged conflicting values.
If spontaneous write (i.e., datum cannot be found in cache), we assume an empty vector clock in the cache and send that to FReD. If there is a newer (any) data item in FReD already, this will fail.