exchange

package
v0.0.0-...-3d82f96 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNameSpaceEmpty   = fmt.Errorf("name space is empty")
	ErrServicesEmpty    = fmt.Errorf("services list is empty")
	ErrDuplicateService = fmt.Errorf("duplicate service name")
	ErrRevProxyStopped  = fmt.Errorf("revproxy is stopped")
	ErrServiceNameEmpty = fmt.Errorf("service name is empty")
	ErrRevProxyStarted  = fmt.Errorf("revproxy is already started")
)
View Source
var ErrConnReqNotFound = fmt.Errorf("connection request not found")

Functions

This section is empty.

Types

type ConnResult

type ConnResult struct {
	Conn net.Conn
	Err  error
}

type ConnectionQueue

type ConnectionQueue interface {
	AddRequest(connChan chan ConnResult) uint64
	AddConnection(id uint64, conn ConnResult) error
}

type MockConnectionQueue

type MockConnectionQueue struct {
	mock.Mock
}

MockConnectionQueue is an autogenerated mock type for the ConnectionQueue type

func NewMockConnectionQueue

func NewMockConnectionQueue(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockConnectionQueue

NewMockConnectionQueue creates a new instance of MockConnectionQueue. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockConnectionQueue) AddConnection

func (_m *MockConnectionQueue) AddConnection(id uint64, conn ConnResult) error

AddConnection provides a mock function with given fields: id, conn

func (*MockConnectionQueue) AddRequest

func (_m *MockConnectionQueue) AddRequest(connChan chan ConnResult) uint64

AddRequest provides a mock function with given fields: connChan

func (*MockConnectionQueue) EXPECT

type MockConnectionQueue_AddConnection_Call

type MockConnectionQueue_AddConnection_Call struct {
	*mock.Call
}

MockConnectionQueue_AddConnection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddConnection'

func (*MockConnectionQueue_AddConnection_Call) Return

func (*MockConnectionQueue_AddConnection_Call) Run

func (*MockConnectionQueue_AddConnection_Call) RunAndReturn

type MockConnectionQueue_AddRequest_Call

type MockConnectionQueue_AddRequest_Call struct {
	*mock.Call
}

MockConnectionQueue_AddRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddRequest'

func (*MockConnectionQueue_AddRequest_Call) Return

func (*MockConnectionQueue_AddRequest_Call) Run

func (*MockConnectionQueue_AddRequest_Call) RunAndReturn

type MockConnectionQueue_Expecter

type MockConnectionQueue_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockConnectionQueue_Expecter) AddConnection

func (_e *MockConnectionQueue_Expecter) AddConnection(id interface{}, conn interface{}) *MockConnectionQueue_AddConnection_Call

AddConnection is a helper method to define mock.On call

  • id uint64
  • conn ConnResult

func (*MockConnectionQueue_Expecter) AddRequest

func (_e *MockConnectionQueue_Expecter) AddRequest(connChan interface{}) *MockConnectionQueue_AddRequest_Call

AddRequest is a helper method to define mock.On call

  • connChan chan ConnResult

type MockRevProxyRepo

type MockRevProxyRepo struct {
	mock.Mock
}

MockRevProxyRepo is an autogenerated mock type for the RevProxyRepo type

func NewMockRevProxyRepo

func NewMockRevProxyRepo(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRevProxyRepo

NewMockRevProxyRepo creates a new instance of MockRevProxyRepo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRevProxyRepo) EXPECT

func (*MockRevProxyRepo) Find

func (_m *MockRevProxyRepo) Find(nameSpace string) (*RevProxy, error)

Find provides a mock function with given fields: nameSpace

func (*MockRevProxyRepo) Register

func (_m *MockRevProxyRepo) Register(proxy *RevProxy)

Register provides a mock function with given fields: proxy

func (*MockRevProxyRepo) Unregister

func (_m *MockRevProxyRepo) Unregister(proxy *RevProxy)

Unregister provides a mock function with given fields: proxy

type MockRevProxyRepo_Expecter

type MockRevProxyRepo_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockRevProxyRepo_Expecter) Find

func (_e *MockRevProxyRepo_Expecter) Find(nameSpace interface{}) *MockRevProxyRepo_Find_Call

Find is a helper method to define mock.On call

  • nameSpace string

func (*MockRevProxyRepo_Expecter) Register

func (_e *MockRevProxyRepo_Expecter) Register(proxy interface{}) *MockRevProxyRepo_Register_Call

Register is a helper method to define mock.On call

  • proxy *RevProxy

func (*MockRevProxyRepo_Expecter) Unregister

func (_e *MockRevProxyRepo_Expecter) Unregister(proxy interface{}) *MockRevProxyRepo_Unregister_Call

Unregister is a helper method to define mock.On call

  • proxy *RevProxy

type MockRevProxyRepo_Find_Call

type MockRevProxyRepo_Find_Call struct {
	*mock.Call
}

MockRevProxyRepo_Find_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Find'

func (*MockRevProxyRepo_Find_Call) Return

func (*MockRevProxyRepo_Find_Call) Run

func (_c *MockRevProxyRepo_Find_Call) Run(run func(nameSpace string)) *MockRevProxyRepo_Find_Call

func (*MockRevProxyRepo_Find_Call) RunAndReturn

type MockRevProxyRepo_Register_Call

type MockRevProxyRepo_Register_Call struct {
	*mock.Call
}

MockRevProxyRepo_Register_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Register'

func (*MockRevProxyRepo_Register_Call) Return

func (*MockRevProxyRepo_Register_Call) Run

func (*MockRevProxyRepo_Register_Call) RunAndReturn

type MockRevProxyRepo_Unregister_Call

type MockRevProxyRepo_Unregister_Call struct {
	*mock.Call
}

MockRevProxyRepo_Unregister_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Unregister'

func (*MockRevProxyRepo_Unregister_Call) Return

func (*MockRevProxyRepo_Unregister_Call) Run

func (*MockRevProxyRepo_Unregister_Call) RunAndReturn

type RevProxy

type RevProxy struct {
	NameSpace string
	Services  []string
	// contains filtered or unexported fields
}

func NewRevProxy

func NewRevProxy(nameSpace string, services []string) (*RevProxy, error)

NewRevProxy creates a new RevProxy with the specified name space and services. It returns an error if the name space is empty or if the services list is empty. It also returns an error if the services list contains duplicate service names. The RevProxy is created with an empty command stream.

func (*RevProxy) CommandStream

func (r *RevProxy) CommandStream() <-chan RevProxyCommand

CommandStream returns a read-only channel of RevProxyCommand. This channel is used to receive commands for the RevProxy. Any commands sent through this channel will be processed by the RevProxy. The returned channel is read-only, meaning it can only be used for receiving commands.

func (*RevProxy) RequestConnection

func (r *RevProxy) RequestConnection(ctx context.Context, id uint64, name string) error

RequestConnection sends a request to establish a connection with the specified ID and name. It returns an error if the context is canceled or if the command cannot be sent to the command stream.

func (*RevProxy) Start

func (r *RevProxy) Start(ctx context.Context) error

Start starts the RevProxy and returns an error if the RevProxy is already running. The RevProxy is started with the specified context.

func (*RevProxy) Stop

func (r *RevProxy) Stop()

Stop stops the RevProxy. It closes the command stream and sets the context to nil.

type RevProxyCommand

type RevProxyCommand struct {
	NameSpace string
	Name      string
	ConnID    uint64
}

type RevProxyRepo

type RevProxyRepo interface {
	Register(proxy *RevProxy)
	Find(nameSpace string) (*RevProxy, error)
	Unregister(proxy *RevProxy)
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(revProxyRepo RevProxyRepo, connQueue ConnectionQueue) *Service

New creates a new instance of the Service. It takes a RevProxyRepo and a ConnectionQueue as parameters. It returns a pointer to the newly created Service.

func (*Service) AddConnection

func (s *Service) AddConnection(id uint64, conn net.Conn) error

AddConnection adds a connection to the connection queue. It returns an error if the connection queue cannot add the connection.

func (*Service) NewConnection

func (s *Service) NewConnection(ctx context.Context, addr *network.Address) (net.Conn, error)

NewConnection creates a new connection. It takes a context and an address as parameters. It returns a net.Conn and an error.

func (*Service) RegisterRevProxy

func (s *Service) RegisterRevProxy(_ context.Context, nameSpace string, services []string) (*RevProxy, error)

RegisterRevProxy registers the reverse connection proxy. It takes a context, namespace, and services as parameters. It returns a pointer to a RevProxy and an error.

func (*Service) UnregisterRevProxy

func (s *Service) UnregisterRevProxy(proxy *RevProxy)

UnregisterRevProxy unregisters the reverse connection proxy. It takes a pointer to a RevProxy as a parameter.

Jump to

Keyboard shortcuts

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