client

package
v0.2.71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 11

Documentation

Overview

Package client implements helpers for gRPC client connection to Agency

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildClientConnBase

func BuildClientConnBase(
	tlsPath, addr string,
	port int,
	opts []grpc.DialOption,
) *rpc.ClientCfg

BuildClientConnBase builds the rpc.ClientCfg from tls path, address, port and opts.g. localhost:50051.

func BuildConnBase

func BuildConnBase(tlsPath, fullAddr string, opts []grpc.DialOption) *rpc.ClientCfg

BuildConnBase builds the rpc.ClientCfg from tls path and full service address including the port e.g. localhost:50051.

func BuildInsecureClientConnBase added in v0.1.41

func BuildInsecureClientConnBase(
	addr string,
	port int,
	opts []grpc.DialOption,
) *rpc.ClientCfg

BuildInsecureClientConnBase is helper to create rpc.ClientCfg easily.

func OkStatus

func OkStatus(s *agency.ProtocolState) bool

Types

type Conn

type Conn struct {
	*grpc.ClientConn
	// contains filtered or unexported fields
}

func TryAuthOpen

func TryAuthOpen(jwtToken string, conf *rpc.ClientCfg) (c Conn)

func TryAuthOpenWithSleep added in v0.1.28

func TryAuthOpenWithSleep(
	jwtToken string,
	conf *rpc.ClientCfg,
	s func(d time.Duration),
) (
	c Conn,
)

TryAuthOpenWithSleep opens authorized gRPC connection with sleep time. nolintlint

func TryOpen

func TryOpen(user string, conf *rpc.ClientCfg) (c Conn)

func (Conn) DoRelease

func (conn Conn) DoRelease(ctx context.Context, id *agency.ProtocolID, cOpts ...grpc.CallOption) (pid *agency.ProtocolID, err error)

func (Conn) DoResume

func (conn Conn) DoResume(ctx context.Context, state *agency.ProtocolState, cOpts ...grpc.CallOption) (pid *agency.ProtocolID, err error)

func (Conn) DoStart

func (conn Conn) DoStart(ctx context.Context, protocol *agency.Protocol, cOpts ...grpc.CallOption) (pid *agency.ProtocolID, err error)

func (Conn) DoStatus

func (conn Conn) DoStatus(ctx context.Context, id *agency.ProtocolID, cOpts ...grpc.CallOption) (status *agency.ProtocolStatus, err error)

func (Conn) Listen

func (conn Conn) Listen(
	ctx context.Context,
	client *agency.ClientID,
	cOpts ...grpc.CallOption,
) (
	ch chan *agency.Question,
	err error,
)

Listen listens both status notifications and agent questions. Client is specified by clientID. Both notifications and questions arriwe from same channel which is Question type.

func (Conn) ListenAndRetry

func (conn Conn) ListenAndRetry(
	ctx context.Context,
	client *agency.ClientID,
	cOpts ...grpc.CallOption,
) (
	ch chan *agency.Question,
)

ListenAndRetry listens both status notifications and agent questions. Client is specified by clientID. Both notifications and questions arriwe from same channel which is Question type. NOTE! This function handles connection errors by itself i.e. it tries to reopen error connnections until its terminated by ctx.Cancel. The actual retry logic is implemented in ListenStatusAndRetry and WaitAndRetry functions.

func (Conn) ListenStatus

func (conn Conn) ListenStatus(
	ctx context.Context,
	client *agency.ClientID,
	cOpts ...grpc.CallOption,
) (
	ch chan *agency.AgentStatus,
	err error,
)

ListenStatus listens agent notification statuses. Client connection is identifed by ClientID. NOTE! The function filters KEEPALIVE messages.

func (Conn) ListenStatusAndRetry

func (conn Conn) ListenStatusAndRetry(
	ctx context.Context,
	client *agency.ClientID,
	cOpts ...grpc.CallOption,
) (
	sch chan *agency.AgentStatus,
)

ListenStatusAndRetry listens agent notification statuses. Client connection is identifed by ClientID. NOTE! This function handles connection errors by itself i.e. it tries to reopen error connnections until its terminated by ctx.Cancel. NOTE! The function filters KEEPALIVE messages.

func (Conn) ListenStatusErr

func (conn Conn) ListenStatusErr(
	ctx context.Context,
	client *agency.ClientID,
	cOpts ...grpc.CallOption,
) (
	ch chan *agency.AgentStatus,
	errCh chan error,
	err error,
)

ListenStatusErr listens agent notification statuses. It terminates on an error and transports it to the caller thru the error channel. Client connection is identifed by ClientID. NOTE! The function filters KEEPALIVE messages.

func (Conn) PSMHook

func (conn Conn) PSMHook(ctx context.Context, cOpts ...grpc.CallOption) (ch chan *ops.AgencyStatus, err error)

func (Conn) Wait

func (conn Conn) Wait(
	ctx context.Context,
	client *agency.ClientID,
	cOpts ...grpc.CallOption,
) (
	ch chan *agency.Question,
	err error,
)

Wait listens agent notification questions. It terminates on error and closes the returned listening channel. Client connection is identifed by ClientID. NOTE! The function filters KEEPALIVE messages.

func (Conn) WaitAndRetry

func (conn Conn) WaitAndRetry(
	ctx context.Context,
	client *agency.ClientID,
	cOpts ...grpc.CallOption,
) (
	ch chan *agency.Question,
)

WaitAndRetry listens agent notification questions. Client connection is identifed by ClientID. NOTE! This function handles connection errors by itself i.e. it tries to reopen error connnections until its terminated by ctx.Cancel. NOTE! The function filters KEEPALIVE messages.

func (Conn) WaitErr

func (conn Conn) WaitErr(
	ctx context.Context,
	client *agency.ClientID,
	cOpts ...grpc.CallOption,
) (
	ch chan *agency.Question,
	errCh chan error,
	err error,
)

WaitErr listens agent notification questions. It terminates on an error and transports it to the caller thru an error channel. Client connection is identifed by ClientID. NOTE! The function filters KEEPALIVE messages.

type Pairwise

type Pairwise struct {
	Conn
	ID    string
	Label string
}

func (Pairwise) BasicMessage

func (pw Pairwise) BasicMessage(
	ctx context.Context,
	content string,
) (
	ch chan *agency.ProtocolState,
	err error,
)

func (*Pairwise) Connection

func (pw *Pairwise) Connection(
	ctx context.Context,
	invitationStr string,
) (
	connID string,
	ch chan *agency.ProtocolState,
	err error,
)

Connection is a helper wrapper to start a connection protocol in the agency. The invitationStr accepts both JSON and URL formated invitations. The agency does the same.

func (Pairwise) Issue

func (pw Pairwise) Issue(
	ctx context.Context,
	credDefID, attrsJSON string,
) (
	ch chan *agency.ProtocolState,
	err error,
)

func (Pairwise) IssueWithAttrs

func (pw Pairwise) IssueWithAttrs(
	ctx context.Context,
	credDefID string,
	attrs *agency.Protocol_IssuingAttributes,
) (
	ch chan *agency.ProtocolState, err error)

func (Pairwise) Ping

func (pw Pairwise) Ping(
	ctx context.Context,
) (
	ch chan *agency.ProtocolState,
	err error,
)

func (Pairwise) ProposeIssue added in v0.1.17

func (pw Pairwise) ProposeIssue(
	ctx context.Context,
	credDefID, attrsJSON string,
) (
	ch chan *agency.ProtocolState,
	err error,
)

func (Pairwise) ProposeIssueWithAttrs added in v0.1.17

func (pw Pairwise) ProposeIssueWithAttrs(
	ctx context.Context,
	credDefID string,
	attrs *agency.Protocol_IssuingAttributes,
) (
	ch chan *agency.ProtocolState, err error)

func (Pairwise) ProposeProof added in v0.1.17

func (pw Pairwise) ProposeProof(
	ctx context.Context,
	proofAttrs string,
) (
	ch chan *agency.ProtocolState,
	err error,
)

func (Pairwise) ProposeProofWithAttrs added in v0.1.17

func (pw Pairwise) ProposeProofWithAttrs(
	ctx context.Context,
	proofAttrs *agency.Protocol_Proof,
) (
	ch chan *agency.ProtocolState,
	err error,
)

func (Pairwise) ReqProof

func (pw Pairwise) ReqProof(
	ctx context.Context,
	proofAttrs string,
) (
	ch chan *agency.ProtocolState,
	err error,
)

func (Pairwise) ReqProofWithAttrs

func (pw Pairwise) ReqProofWithAttrs(
	ctx context.Context,
	proofAttrs *agency.Protocol_Proof,
) (
	ch chan *agency.ProtocolState,
	err error,
)

func (*Pairwise) WaitConnection added in v0.1.23

func (pw *Pairwise) WaitConnection(
	ctx context.Context,
	invitationStr string,
) (
	connID string,
	ch chan *agency.ProtocolState,
	err error,
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL