Documentation ¶
Overview ¶
Package centralized defines a client-server-based transport for the helium services. This transport is based on gRPC services.
Index ¶
- Constants
- type CiphertextHandler
- type Dialer
- type HeliumClient
- func (hc *HeliumClient) Connect() error
- func (hc *HeliumClient) ConnectWithDialer(dialer Dialer) error
- func (hc *HeliumClient) GetAggregationOutput(ctx context.Context, pd protocols.Descriptor) (*protocols.AggregationOutput, error)
- func (hc *HeliumClient) GetCiphertext(ctx context.Context, ctID helium.CiphertextID) (*helium.Ciphertext, error)
- func (s *HeliumClient) GetStats() NetStats
- func (s *HeliumClient) HandleConn(_ context.Context, _ stats.ConnStats)
- func (s *HeliumClient) HandleRPC(_ context.Context, sta stats.RPCStats)
- func (hc *HeliumClient) PutCiphertext(ctx context.Context, ct helium.Ciphertext) error
- func (hc *HeliumClient) PutShare(ctx context.Context, share protocols.Share) error
- func (hc *HeliumClient) Register(ctx context.Context) (events <-chan coordinator.Event, present int, err error)
- func (s *HeliumClient) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context
- func (s *HeliumClient) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context
- type HeliumServer
- func (hsv *HeliumServer) AppendEventToLog(event coordinator.Event) error
- func (hsv *HeliumServer) CloseEventLog()
- func (hsv *HeliumServer) GetAggregationOutput(inctx context.Context, apipd *pb.ProtocolDescriptor) (*pb.AggregationOutput, error)
- func (hsv *HeliumServer) GetCiphertext(inctx context.Context, ctid *pb.CiphertextID) (*pb.Ciphertext, error)
- func (s *HeliumServer) GetStats() NetStats
- func (s *HeliumServer) HandleConn(_ context.Context, _ stats.ConnStats)
- func (s *HeliumServer) HandleRPC(_ context.Context, sta stats.RPCStats)
- func (hsv *HeliumServer) Logf(msg string, v ...any)
- func (hsv *HeliumServer) NotifyRegister(node helium.NodeID) (err error)
- func (hsv *HeliumServer) NotifyUnregister(node helium.NodeID) (err error)
- func (hsv *HeliumServer) PutCiphertext(inctx context.Context, apict *pb.Ciphertext) (*pb.CiphertextID, error)
- func (hsv *HeliumServer) PutShare(inctx context.Context, apiShare *pb.Share) (*pb.Void, error)
- func (hsv *HeliumServer) Register(_ *pb.Void, stream pb.Helium_RegisterServer) error
- func (hsv *HeliumServer) RegisterWatcher(nw NodeWatcher)
- func (s *HeliumServer) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context
- func (s *HeliumServer) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context
- type NetStats
- type NodeWatcher
- type ProtocolHandler
- type TLSConfig
Constants ¶
const ( MaxMsgSize = 1024 * 1024 * 32 KeepaliveTime = time.Second KeepaliveTimeout = time.Second )
const (
ClientConnectTimeout = 3 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CiphertextHandler ¶
type CiphertextHandler interface { GetCiphertext(context.Context, helium.CiphertextID) (*helium.Ciphertext, error) PutCiphertext(context.Context, helium.Ciphertext) error }
CiphertextHandler is an interface for the helium server to handle ciphertext-related requests from its peers. The interface implementation is provided by the NewHeliumServer method, and the created server makes calls to the interface methods when handling requests from its peers.
type HeliumClient ¶
type HeliumClient struct { pb.HeliumClient // contains filtered or unexported fields }
HeliumClient is a client for the helium service. It is used by peer nodes to communicate with the helium server.
func NewHeliumClient ¶
func NewHeliumClient(ownID, helperID helium.NodeID, helperAddress helium.NodeAddress) *HeliumClient
NewHeliumClient creates a new helium client.
func (*HeliumClient) Connect ¶
func (hc *HeliumClient) Connect() error
Connect establishes a connection to the helium server.
func (*HeliumClient) ConnectWithDialer ¶
func (hc *HeliumClient) ConnectWithDialer(dialer Dialer) error
ConnectWithDialer establishes a connection to the helium server using the provided dialer.
func (*HeliumClient) GetAggregationOutput ¶
func (hc *HeliumClient) GetAggregationOutput(ctx context.Context, pd protocols.Descriptor) (*protocols.AggregationOutput, error)
GetAggregationOutput queries and returns the aggregation output for a given protocol descriptor.
func (*HeliumClient) GetCiphertext ¶
func (hc *HeliumClient) GetCiphertext(ctx context.Context, ctID helium.CiphertextID) (*helium.Ciphertext, error)
GetCiphertext queries and returns a ciphertext.
func (*HeliumClient) HandleConn ¶
HandleConn processes the Conn stats.
func (*HeliumClient) PutCiphertext ¶
func (hc *HeliumClient) PutCiphertext(ctx context.Context, ct helium.Ciphertext) error
PutCiphertext sends a ciphertext to the helium server.
func (*HeliumClient) Register ¶
func (hc *HeliumClient) Register(ctx context.Context) (events <-chan coordinator.Event, present int, err error)
Register registers the client with the helium server and returns a channel for receiving events. It returns the current sequence number for the event log as present. Reading present+1 events from the returned channel will not block for longer than network-introduced delays.
func (*HeliumClient) TagConn ¶
TagConn can attach some information to the given context. The returned context will be used for stats handling. For conn stats handling, the context used in HandleConn for this connection will be derived from the context returned. For RPC stats handling,
- On server side, the context used in HandleRPC for all RPCs on this
connection will be derived from the context returned.
- On client side, the context is not derived from the context returned.
type HeliumServer ¶
type HeliumServer struct { // grpc API *grpc.Server *pb.UnimplementedHeliumServer // contains filtered or unexported fields }
HeliumServer is the server-side of the helium transport. In the current implementation, the server is responsible for keeping the event log and a server cannot be restarted after it is closed. // TODO
func NewHeliumServer ¶
func NewHeliumServer(id helium.NodeID, na helium.NodeAddress, nl helium.NodesList, protoHandler ProtocolHandler, ctxtHandler CiphertextHandler) *HeliumServer
NewHeliumServer creates a new helium server with the provided node information and handlers.
func (*HeliumServer) AppendEventToLog ¶
func (hsv *HeliumServer) AppendEventToLog(event coordinator.Event) error
AppendEventToLog is called by the server side to append a new event to the log and send it to all connected peers.
func (*HeliumServer) CloseEventLog ¶
func (hsv *HeliumServer) CloseEventLog()
CloseEventLog is called by the server side to close the event log and stop sending events to connected peers.
func (*HeliumServer) GetAggregationOutput ¶
func (hsv *HeliumServer) GetAggregationOutput(inctx context.Context, apipd *pb.ProtocolDescriptor) (*pb.AggregationOutput, error)
GetAggregationOutput is a gRPC handler for the GetAggregationOutput method of the Helium service.
func (*HeliumServer) GetCiphertext ¶
func (hsv *HeliumServer) GetCiphertext(inctx context.Context, ctid *pb.CiphertextID) (*pb.Ciphertext, error)
GetCiphertext is a gRPC handler for the GetCiphertext method of the Helium service.
func (*HeliumServer) HandleConn ¶
HandleConn processes the Conn stats.
func (*HeliumServer) Logf ¶
func (hsv *HeliumServer) Logf(msg string, v ...any)
func (*HeliumServer) NotifyRegister ¶
func (hsv *HeliumServer) NotifyRegister(node helium.NodeID) (err error)
NotifyRegister notifies all registered watchers that a new peer has registered.
func (*HeliumServer) NotifyUnregister ¶
func (hsv *HeliumServer) NotifyUnregister(node helium.NodeID) (err error)
NotifyUnregister notifies all registered watchers that a peer has unregistered.
func (*HeliumServer) PutCiphertext ¶
func (hsv *HeliumServer) PutCiphertext(inctx context.Context, apict *pb.Ciphertext) (*pb.CiphertextID, error)
PutCiphertext is a gRPC handler for the PutCiphertext method of the Helium service.
func (*HeliumServer) PutShare ¶
PutShare is a gRPC handler for the PutShare method of the Helium service.
func (*HeliumServer) Register ¶
func (hsv *HeliumServer) Register(_ *pb.Void, stream pb.Helium_RegisterServer) error
Register is a gRPC handler for the Register method of the Helium service.
func (*HeliumServer) RegisterWatcher ¶
func (hsv *HeliumServer) RegisterWatcher(nw NodeWatcher)
RegisterWatcher adds a new watcher to the server. The watcher will be notified when a new peer is registered
func (*HeliumServer) TagConn ¶
TagConn can attach some information to the given context. The returned context will be used for stats handling. For conn stats handling, the context used in HandleConn for this connection will be derived from the context returned. For RPC stats handling,
- On server side, the context used in HandleRPC for all RPCs on this
connection will be derived from the context returned.
- On client side, the context is not derived from the context returned.
type NetStats ¶
type NetStats struct {
DataSent, DataRecv uint64
}
NetStats contains the network statistics of a connection.
type NodeWatcher ¶
type NodeWatcher interface { // Register is called by the transport when a new peer register itself for the setup. Register(helium.NodeID) error // Unregister is called by the transport when a peer is unregistered from the setup. Unregister(helium.NodeID) error }
NodeWatcher is an interface for the helium server to notify registered watchers when a new peer is registered or unregistered. See HeliumServer.RegisterWatcher.
type ProtocolHandler ¶
type ProtocolHandler interface { GetAggregationOutput(context.Context, protocols.Descriptor) (*protocols.AggregationOutput, error) }
ProtocolHandler is an interface for the helium server to handle protocol-related requests from its peers. The interface implementation is provided by the NewHeliumServer method, and the created server makes calls to the interface methods when handling requests from its peers.
type TLSConfig ¶
type TLSConfig struct { InsecureChannels bool // if set, disables TLS authentication FromDirectory string // path to a directory containing the TLS material as files PeerPKs map[helium.NodeID]string // Mapping of <node, pubKey> where pubKey is PEM encoded PeerCerts map[helium.NodeID]string // Mapping of <node, certifcate> where pubKey is PEM encoded ASN.1 DER string CACert string // Root CA certificate as a PEM encoded ASN.1 DER string OwnCert string // Own certificate as a PEM encoded ASN.1 DER string OwnPk string // Own public key as a PEM encoded string OwnSk string // Own secret key as a PEM encoded string }
TLSConfig is a struct for specifying TLS-related configuration. TLS is not supported yet.