Documentation ¶
Index ¶
- func CreateKeysClient(ctx context.Context, address string) (rusk.KeysClient, *grpc.ClientConn)
- func CreateNetworkClient(ctx context.Context, address string) (rusk.NetworkClient, *grpc.ClientConn)
- func CreateStakeClient(ctx context.Context, address string) (rusk.StakeServiceClient, *grpc.ClientConn)
- func CreateStateClient(ctx context.Context, address string) (rusk.StateClient, *grpc.ClientConn)
- func CreateTransferClient(ctx context.Context, address string) (rusk.TransferClient, *grpc.ClientConn)
- func ScheduleRefreshToken(ctx context.Context, client *AuthClient, interceptor *AuthClientInterceptor, ...)
- type AuthClient
- type AuthClientInterceptor
- type NodeClient
- func (n *NodeClient) Close()
- func (n *NodeClient) DropSession(options ...grpc.DialOption) error
- func (n *NodeClient) GetSessionConn(options ...grpc.DialOption) (*grpc.ClientConn, error)
- func (n *NodeClient) GracefulClose(opts ...grpc.DialOption)
- func (n *NodeClient) IsSessionActive() bool
- func (n *NodeClient) PublicKey() []byte
- func (n *NodeClient) ScheduleSessionRefresh(cadence time.Time, options ...grpc.DialOption) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateKeysClient ¶
func CreateKeysClient(ctx context.Context, address string) (rusk.KeysClient, *grpc.ClientConn)
CreateKeysClient creates a client for the Keys service.
func CreateNetworkClient ¶ added in v0.4.4
func CreateNetworkClient(ctx context.Context, address string) (rusk.NetworkClient, *grpc.ClientConn)
CreateNetworkClient creates a client for the Kadcast network layer.
func CreateStakeClient ¶
func CreateStakeClient(ctx context.Context, address string) (rusk.StakeServiceClient, *grpc.ClientConn)
CreateStakeClient creates a client for the Stake service.
func CreateStateClient ¶
func CreateStateClient(ctx context.Context, address string) (rusk.StateClient, *grpc.ClientConn)
CreateStateClient opens the connection with the Rusk gRPC server, and initializes the different clients which can speak to the Rusk server.
As the Rusk server is a fundamental part of the node functionality, this function will panic if the connection can not be established successfully. FIXME: we need to add the TLS certificates to both ends to encrypt the channel. QUESTION: should this function be triggered everytime we wanna query RUSK or the client can remain connected? NOTE: the grpc client connections should be reused for the lifetime of the client. For this reason, we do not set a timeout at this stage.
func CreateTransferClient ¶
func CreateTransferClient(ctx context.Context, address string) (rusk.TransferClient, *grpc.ClientConn)
CreateTransferClient creates a client for the Transfer service.
func ScheduleRefreshToken ¶
func ScheduleRefreshToken(ctx context.Context, client *AuthClient, interceptor *AuthClientInterceptor, refresh time.Time, retries int, errChan chan error)
ScheduleRefreshToken is supposed to run in a goroutine. It refreshes the session token according to the specified refresh frequency.
Types ¶
type AuthClient ¶
type AuthClient struct {
// contains filtered or unexported fields
}
AuthClient is the client used to test the authorization service.
func NewClient ¶
func NewClient(cc *grpc.ClientConn, edPk ed25519.PublicKey, edSk ed25519.PrivateKey) *AuthClient
NewClient returns a new AuthClient and AuthClientInterceptor.
func (*AuthClient) CreateSession ¶
func (c *AuthClient) CreateSession() (string, error)
CreateSession creates a JWT.
func (*AuthClient) DropSession ¶
func (c *AuthClient) DropSession() error
DropSession deletes the user PK from the set.
type AuthClientInterceptor ¶
type AuthClientInterceptor struct {
// contains filtered or unexported fields
}
AuthClientInterceptor handles the authorization for the grpc systems.
func NewClientInterceptor ¶
func NewClientInterceptor(edPk ed25519.PublicKey, edSk ed25519.PrivateKey) *AuthClientInterceptor
NewClientInterceptor injects the session to the outgoing requests.
func (*AuthClientInterceptor) SetAccessToken ¶
func (i *AuthClientInterceptor) SetAccessToken(accessToken string)
SetAccessToken sets the session token in a threadsafe way.
func (*AuthClientInterceptor) Unary ¶
func (i *AuthClientInterceptor) Unary() grpc.UnaryClientInterceptor
Unary returns the grpc unary interceptor. It implictly saves the access token when a new session is created and drops it when the session gets explicitly dropped.
type NodeClient ¶
type NodeClient struct {
// contains filtered or unexported fields
}
NodeClient is a wrapper for the grpc node service client. It takes care of handling the session on behalf of the caller by maintaining a grpc interceptor.
func New ¶
func New(proto, addr string) *NodeClient
New creates a new NodeClient which takes care of maintaining the session.
func (*NodeClient) Close ¶
func (n *NodeClient) Close()
Close the client without notifying the server to close the session.
func (*NodeClient) DropSession ¶
func (n *NodeClient) DropSession(options ...grpc.DialOption) error
DropSession closes a session, invalidate the session token and closes the persistent connection gracefully.
func (*NodeClient) GetSessionConn ¶
func (n *NodeClient) GetSessionConn(options ...grpc.DialOption) (*grpc.ClientConn, error)
GetSessionConn triggers a CreateSession through the auth client and implicitly populates the interceptor with the session token. It returns a new connection or an error.
func (*NodeClient) GracefulClose ¶
func (n *NodeClient) GracefulClose(opts ...grpc.DialOption)
GracefulClose cancels the session refresh and actively drops the session.
func (*NodeClient) IsSessionActive ¶
func (n *NodeClient) IsSessionActive() bool
IsSessionActive returns whether the session is active or otherwise.
func (*NodeClient) PublicKey ¶
func (n *NodeClient) PublicKey() []byte
PublicKey returns the serialized binary array of the public key of this node client.
func (*NodeClient) ScheduleSessionRefresh ¶
func (n *NodeClient) ScheduleSessionRefresh(cadence time.Time, options ...grpc.DialOption) error
ScheduleSessionRefresh refreshes the session with the specified cadence.