Documentation ¶
Index ¶
- Constants
- type Client
- type ClientsMgr
- type Middleware
- func (m *Middleware) AddReplica(ctx context.Context, req *middleware.AddReplicaRequest) (*middleware.Empty, error)
- func (m *Middleware) AddTrigger(ctx context.Context, req *middleware.AddTriggerRequest) (*middleware.Empty, error)
- func (m *Middleware) AddUser(ctx context.Context, req *middleware.UserRequest) (*middleware.Empty, error)
- func (m *Middleware) Append(ctx context.Context, req *middleware.AppendRequest) (*middleware.AppendResponse, error)
- func (m *Middleware) ChooseReplica(_ context.Context, req *middleware.ChooseReplicaRequest) (*middleware.Empty, error)
- func (m *Middleware) CreateKeygroup(ctx context.Context, req *middleware.CreateKeygroupRequest) (*middleware.Empty, error)
- func (m *Middleware) Delete(ctx context.Context, req *middleware.DeleteRequest) (*middleware.Empty, error)
- func (m *Middleware) DeleteKeygroup(ctx context.Context, req *middleware.DeleteKeygroupRequest) (*middleware.Empty, error)
- func (m *Middleware) GetAllReplica(ctx context.Context, _ *middleware.GetAllReplicaRequest) (*middleware.GetAllReplicaResponse, error)
- func (m *Middleware) GetKeygroupInfo(ctx context.Context, req *middleware.GetKeygroupInfoRequest) (*middleware.GetKeygroupInfoResponse, error)
- func (m *Middleware) GetKeygroupTriggers(ctx context.Context, req *middleware.GetKeygroupTriggerRequest) (*middleware.GetKeygroupTriggerResponse, error)
- func (m *Middleware) GetReplica(ctx context.Context, req *middleware.GetReplicaRequest) (*middleware.GetReplicaResponse, error)
- func (m *Middleware) Notify(_ context.Context, req *middleware.NotifyRequest) (*middleware.Empty, error)
- func (m *Middleware) Read(_ context.Context, req *middleware.ReadRequest) (*middleware.ReadResponse, error)
- func (m *Middleware) RemoveReplica(ctx context.Context, req *middleware.RemoveReplicaRequest) (*middleware.Empty, error)
- func (m *Middleware) RemoveTrigger(ctx context.Context, req *middleware.RemoveTriggerRequest) (*middleware.Empty, error)
- func (m *Middleware) RemoveUser(ctx context.Context, req *middleware.UserRequest) (*middleware.Empty, error)
- func (m *Middleware) Scan(ctx context.Context, req *middleware.ScanRequest) (*middleware.ScanResponse, error)
- func (m *Middleware) 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 Middleware ¶ added in v0.2.3
type Middleware struct {
// contains filtered or unexported fields
}
Middleware 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 NewMiddleware ¶ added in v0.2.3
func NewMiddleware(nodesCert string, nodesKey string, caCert string, lighthouse string, isProxied bool, proxyHost string, experimental bool) *Middleware
NewMiddleware creates a new Middleware for requests from Alexandra Clients
func (*Middleware) AddReplica ¶ added in v0.2.3
func (m *Middleware) 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 (*Middleware) AddTrigger ¶ added in v0.2.3
func (m *Middleware) AddTrigger(ctx context.Context, req *middleware.AddTriggerRequest) (*middleware.Empty, error)
AddTrigger adds a new trigger to a keygroup.
func (*Middleware) AddUser ¶ added in v0.2.3
func (m *Middleware) AddUser(ctx context.Context, req *middleware.UserRequest) (*middleware.Empty, error)
AddUser adds permissions to access a keygroup for a particular user to FReD.
func (*Middleware) Append ¶ added in v0.2.3
func (m *Middleware) 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 (*Middleware) ChooseReplica ¶ added in v0.2.3
func (m *Middleware) ChooseReplica(_ context.Context, req *middleware.ChooseReplicaRequest) (*middleware.Empty, error)
ChooseReplica allows a client to choose a particular note to send requests to for a keygroup. This will override the fastest node if exists
func (*Middleware) CreateKeygroup ¶ added in v0.2.3
func (m *Middleware) 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 (*Middleware) Delete ¶ added in v0.2.3
func (m *Middleware) 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 (*Middleware) DeleteKeygroup ¶ added in v0.2.3
func (m *Middleware) DeleteKeygroup(ctx context.Context, req *middleware.DeleteKeygroupRequest) (*middleware.Empty, error)
DeleteKeygroup deletes a keygroup from FReD.
func (*Middleware) GetAllReplica ¶ added in v0.2.3
func (m *Middleware) 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 (*Middleware) GetKeygroupInfo ¶ added in v0.2.3
func (m *Middleware) GetKeygroupInfo(ctx context.Context, req *middleware.GetKeygroupInfoRequest) (*middleware.GetKeygroupInfoResponse, error)
GetKeygroupInfo 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 (*Middleware) GetKeygroupTriggers ¶ added in v0.2.3
func (m *Middleware) GetKeygroupTriggers(ctx context.Context, req *middleware.GetKeygroupTriggerRequest) (*middleware.GetKeygroupTriggerResponse, error)
GetKeygroupTriggers returns a list of trigger nodes for a keygroup.
func (*Middleware) GetReplica ¶ added in v0.2.3
func (m *Middleware) 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 (*Middleware) Notify ¶ added in v0.2.3
func (m *Middleware) Notify(_ context.Context, req *middleware.NotifyRequest) (*middleware.Empty, 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 (*Middleware) Read ¶ added in v0.2.3
func (m *Middleware) 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 (*Middleware) RemoveReplica ¶ added in v0.2.3
func (m *Middleware) 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 (*Middleware) RemoveTrigger ¶ added in v0.2.3
func (m *Middleware) RemoveTrigger(ctx context.Context, req *middleware.RemoveTriggerRequest) (*middleware.Empty, error)
RemoveTrigger removes a trigger node for a keygroup.
func (*Middleware) RemoveUser ¶ added in v0.2.3
func (m *Middleware) RemoveUser(ctx context.Context, req *middleware.UserRequest) (*middleware.Empty, error)
RemoveUser removes permissions to access a keygroup for a particular user from FReD.
func (*Middleware) Scan ¶ added in v0.2.3
func (m *Middleware) 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 (*Middleware) Update ¶ added in v0.2.3
func (m *Middleware) 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.