gds

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyConnected = errors.New("already connected to directory, cannot overide dialer")
	ErrNotConnected     = errors.New("not connected to directory service")
)

Functions

This section is empty.

Types

type Directory

type Directory interface {
	Lookup(ctx context.Context, in *gds.LookupRequest, opts ...grpc.CallOption) (*gds.LookupReply, error)
	Search(ctx context.Context, in *gds.SearchRequest, opts ...grpc.CallOption) (*gds.SearchReply, error)
	Summary(ctx context.Context, in *members.SummaryRequest, opts ...grpc.CallOption) (*members.SummaryReply, error)
	List(ctx context.Context, in *members.ListRequest, opts ...grpc.CallOption) (*members.ListReply, error)
	Detail(ctx context.Context, in *members.DetailsRequest, opts ...grpc.CallOption) (*members.MemberDetails, error)
	Status(ctx context.Context, in *gds.HealthCheck, opts ...grpc.CallOption) (*gds.ServiceState, error)
	Connect(opts ...grpc.DialOption) error
	Close() error
}

Directory implements a client-side selection of interactions with the TRISA Global Directory Service, e.g. Lookup and Search from the TRISADirectoryClient and List from the TRISAMembersClient interfaces. A Directory is used to manage TRISA network peers.

type GDS

type GDS struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

GDS implements the Directory interface to interact with the TRISA Global Directory Service.

func New

func New(conf config.TRISAConfig) *GDS

func (*GDS) Close

func (g *GDS) Close() (err error)

func (*GDS) Connect

func (g *GDS) Connect(opts ...grpc.DialOption) (err error)

Connect to the directory service by dialing the configured endpoints with the specified options and credentials. If no options are supplied, the Connect function attempts to connect using default options. The endpoints connected to are defined by the directory configuration. Returns an error if the GDS is already connected.

func (*GDS) Detail

func (*GDS) List

func (g *GDS) List(ctx context.Context, in *members.ListRequest, opts ...grpc.CallOption) (*members.ListReply, error)

func (*GDS) Lookup

func (g *GDS) Lookup(ctx context.Context, in *gds.LookupRequest, opts ...grpc.CallOption) (*gds.LookupReply, error)

func (*GDS) Search

func (g *GDS) Search(ctx context.Context, in *gds.SearchRequest, opts ...grpc.CallOption) (*gds.SearchReply, error)

func (*GDS) Status

func (g *GDS) Status(ctx context.Context, in *gds.HealthCheck, opts ...grpc.CallOption) (*gds.ServiceState, error)

func (*GDS) String

func (g *GDS) String() string

String returns the name of the directory service being connected to by parsing the root domain from the endpoint and stripping the port. E.g. api.trisatest.net:443 becomes trisatest.net and localhost:4436 becomes localhost.

func (*GDS) Summary

func (g *GDS) Summary(ctx context.Context, in *members.SummaryRequest, opts ...grpc.CallOption) (*members.SummaryReply, error)

type MockGDS

type MockGDS struct {
	GDS
	// contains filtered or unexported fields
}

MockGDS implements all of the functionality of the GDS and implements the Directory interface because a GDS is embedded. However, instead of connecting to a live directory or requiring a TRISA config, it connects to a mock GDS server via bufconn to allow robust testing outside of the package.

NOTE: the internal package tests test the GDS object directly, the MockGDS object should only be be used for tests outside of the package.

func NewMock

func NewMock(conf config.TRISAConfig) *MockGDS

func (*MockGDS) Close

func (m *MockGDS) Close() (err error)

func (*MockGDS) Connect

func (m *MockGDS) Connect(opts ...grpc.DialOption) (err error)

func (*MockGDS) GetBufnet

func (m *MockGDS) GetBufnet() *bufconn.Listener

func (*MockGDS) GetMock

func (m *MockGDS) GetMock() *mock.GDS

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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