network

package
v0.0.0-...-543ca17 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	io.Closer
	OnClose(func()) Conn
	// Local returns the name of the local peer
	Local() dndm.Peer
	// Remote returns the name of the remote peer
	Remote() dndm.Peer
	// UpdateRemotePeer sets the remote peer name. Peer scheme and address must match to take effect.
	UpdateRemotePeer(dndm.Peer) error
	// Read reads a message sent by the peer
	Read(ctx context.Context) (*types.Header, proto.Message, error)
	// Write sends a message to the peer
	Write(ctx context.Context, route dndm.Route, msg proto.Message) error

	// AddRoute registers a route type. NOTE: Route must have a valid Type
	AddRoute(...dndm.Route)
	// DelRoute unregisters a route type.
	DelRoute(...dndm.Route)
}

Conn interface represents a communication channel with the remote peer

type DialOpt

type DialOpt func(*DialOptStruct) error

type DialOptStruct

type DialOptStruct struct {
}

type Dialer

type Dialer interface {
	// Scheme returns the scheme this dialer handles
	Scheme() string
	// Dial dials the remote peer and returns a ReadeWriteCloser object
	Dial(ctx context.Context, peer dndm.Peer, o ...DialOpt) (io.ReadWriteCloser, error)
}

Dialer interface describes objects that can dial a remote peer.

type Factory

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

func New

func New(dialers ...Dialer) (*Factory, error)

func (*Factory) Dial

func (f *Factory) Dial(ctx context.Context, peer dndm.Peer, o ...DialOpt) (io.ReadWriteCloser, error)

func (*Factory) Scheme

func (f *Factory) Scheme() string

func (*Factory) Serve

func (f *Factory) Serve(ctx context.Context, onConnect func(peer dndm.Peer, r io.ReadWriteCloser) error, o ...SrvOpt) error

type MessageHandler

type MessageHandler func(hdr *types.Header, msg proto.Message, remote Conn) (pass bool, err error)

type MockConn

type MockConn struct {
	mock.Mock
}

MockConn is an autogenerated mock type for the Conn type

func NewMockConn

func NewMockConn(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockConn

NewMockConn creates a new instance of MockConn. 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 (*MockConn) AddRoute

func (_m *MockConn) AddRoute(_a0 ...dndm.Route)

AddRoute provides a mock function with given fields: _a0

func (*MockConn) Close

func (_m *MockConn) Close() error

Close provides a mock function with given fields:

func (*MockConn) DelRoute

func (_m *MockConn) DelRoute(_a0 ...dndm.Route)

DelRoute provides a mock function with given fields: _a0

func (*MockConn) EXPECT

func (_m *MockConn) EXPECT() *MockConn_Expecter

func (*MockConn) Local

func (_m *MockConn) Local() dndm.Peer

Local provides a mock function with given fields:

func (*MockConn) OnClose

func (_m *MockConn) OnClose(_a0 func()) Conn

OnClose provides a mock function with given fields: _a0

func (*MockConn) Read

Read provides a mock function with given fields: ctx

func (*MockConn) Remote

func (_m *MockConn) Remote() dndm.Peer

Remote provides a mock function with given fields:

func (*MockConn) UpdateRemotePeer

func (_m *MockConn) UpdateRemotePeer(_a0 dndm.Peer) error

UpdateRemotePeer provides a mock function with given fields: _a0

func (*MockConn) Write

func (_m *MockConn) Write(ctx context.Context, route dndm.Route, msg protoreflect.ProtoMessage) error

Write provides a mock function with given fields: ctx, route, msg

type MockConn_AddRoute_Call

type MockConn_AddRoute_Call struct {
	*mock.Call
}

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

func (*MockConn_AddRoute_Call) Return

func (*MockConn_AddRoute_Call) Run

func (_c *MockConn_AddRoute_Call) Run(run func(_a0 ...dndm.Route)) *MockConn_AddRoute_Call

func (*MockConn_AddRoute_Call) RunAndReturn

func (_c *MockConn_AddRoute_Call) RunAndReturn(run func(...dndm.Route)) *MockConn_AddRoute_Call

type MockConn_Close_Call

type MockConn_Close_Call struct {
	*mock.Call
}

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

func (*MockConn_Close_Call) Return

func (*MockConn_Close_Call) Run

func (_c *MockConn_Close_Call) Run(run func()) *MockConn_Close_Call

func (*MockConn_Close_Call) RunAndReturn

func (_c *MockConn_Close_Call) RunAndReturn(run func() error) *MockConn_Close_Call

type MockConn_DelRoute_Call

type MockConn_DelRoute_Call struct {
	*mock.Call
}

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

func (*MockConn_DelRoute_Call) Return

func (*MockConn_DelRoute_Call) Run

func (_c *MockConn_DelRoute_Call) Run(run func(_a0 ...dndm.Route)) *MockConn_DelRoute_Call

func (*MockConn_DelRoute_Call) RunAndReturn

func (_c *MockConn_DelRoute_Call) RunAndReturn(run func(...dndm.Route)) *MockConn_DelRoute_Call

type MockConn_Expecter

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

func (*MockConn_Expecter) AddRoute

func (_e *MockConn_Expecter) AddRoute(_a0 ...interface{}) *MockConn_AddRoute_Call

AddRoute is a helper method to define mock.On call

  • _a0 ...dndm.Route

func (*MockConn_Expecter) Close

Close is a helper method to define mock.On call

func (*MockConn_Expecter) DelRoute

func (_e *MockConn_Expecter) DelRoute(_a0 ...interface{}) *MockConn_DelRoute_Call

DelRoute is a helper method to define mock.On call

  • _a0 ...dndm.Route

func (*MockConn_Expecter) Local

Local is a helper method to define mock.On call

func (*MockConn_Expecter) OnClose

func (_e *MockConn_Expecter) OnClose(_a0 interface{}) *MockConn_OnClose_Call

OnClose is a helper method to define mock.On call

  • _a0 func()

func (*MockConn_Expecter) Read

func (_e *MockConn_Expecter) Read(ctx interface{}) *MockConn_Read_Call

Read is a helper method to define mock.On call

  • ctx context.Context

func (*MockConn_Expecter) Remote

Remote is a helper method to define mock.On call

func (*MockConn_Expecter) UpdateRemotePeer

func (_e *MockConn_Expecter) UpdateRemotePeer(_a0 interface{}) *MockConn_UpdateRemotePeer_Call

UpdateRemotePeer is a helper method to define mock.On call

  • _a0 dndm.Peer

func (*MockConn_Expecter) Write

func (_e *MockConn_Expecter) Write(ctx interface{}, route interface{}, msg interface{}) *MockConn_Write_Call

Write is a helper method to define mock.On call

  • ctx context.Context
  • route dndm.Route
  • msg protoreflect.ProtoMessage

type MockConn_Local_Call

type MockConn_Local_Call struct {
	*mock.Call
}

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

func (*MockConn_Local_Call) Return

func (*MockConn_Local_Call) Run

func (_c *MockConn_Local_Call) Run(run func()) *MockConn_Local_Call

func (*MockConn_Local_Call) RunAndReturn

func (_c *MockConn_Local_Call) RunAndReturn(run func() dndm.Peer) *MockConn_Local_Call

type MockConn_OnClose_Call

type MockConn_OnClose_Call struct {
	*mock.Call
}

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

func (*MockConn_OnClose_Call) Return

func (*MockConn_OnClose_Call) Run

func (_c *MockConn_OnClose_Call) Run(run func(_a0 func())) *MockConn_OnClose_Call

func (*MockConn_OnClose_Call) RunAndReturn

func (_c *MockConn_OnClose_Call) RunAndReturn(run func(func()) Conn) *MockConn_OnClose_Call

type MockConn_Read_Call

type MockConn_Read_Call struct {
	*mock.Call
}

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

func (*MockConn_Read_Call) Return

func (*MockConn_Read_Call) Run

func (_c *MockConn_Read_Call) Run(run func(ctx context.Context)) *MockConn_Read_Call

func (*MockConn_Read_Call) RunAndReturn

type MockConn_Remote_Call

type MockConn_Remote_Call struct {
	*mock.Call
}

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

func (*MockConn_Remote_Call) Return

func (*MockConn_Remote_Call) Run

func (_c *MockConn_Remote_Call) Run(run func()) *MockConn_Remote_Call

func (*MockConn_Remote_Call) RunAndReturn

func (_c *MockConn_Remote_Call) RunAndReturn(run func() dndm.Peer) *MockConn_Remote_Call

type MockConn_UpdateRemotePeer_Call

type MockConn_UpdateRemotePeer_Call struct {
	*mock.Call
}

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

func (*MockConn_UpdateRemotePeer_Call) Return

func (*MockConn_UpdateRemotePeer_Call) Run

func (*MockConn_UpdateRemotePeer_Call) RunAndReturn

type MockConn_Write_Call

type MockConn_Write_Call struct {
	*mock.Call
}

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

func (*MockConn_Write_Call) Return

func (*MockConn_Write_Call) Run

func (*MockConn_Write_Call) RunAndReturn

type MockDialer

type MockDialer struct {
	mock.Mock
}

MockDialer is an autogenerated mock type for the Dialer type

func NewMockDialer

func NewMockDialer(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockDialer

NewMockDialer creates a new instance of MockDialer. 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 (*MockDialer) Dial

func (_m *MockDialer) Dial(ctx context.Context, peer dndm.Peer, o ...DialOpt) (io.ReadWriteCloser, error)

Dial provides a mock function with given fields: ctx, peer, o

func (*MockDialer) EXPECT

func (_m *MockDialer) EXPECT() *MockDialer_Expecter

func (*MockDialer) Scheme

func (_m *MockDialer) Scheme() string

Scheme provides a mock function with given fields:

type MockDialer_Dial_Call

type MockDialer_Dial_Call struct {
	*mock.Call
}

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

func (*MockDialer_Dial_Call) Return

func (*MockDialer_Dial_Call) Run

func (_c *MockDialer_Dial_Call) Run(run func(ctx context.Context, peer dndm.Peer, o ...DialOpt)) *MockDialer_Dial_Call

func (*MockDialer_Dial_Call) RunAndReturn

type MockDialer_Expecter

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

func (*MockDialer_Expecter) Dial

func (_e *MockDialer_Expecter) Dial(ctx interface{}, peer interface{}, o ...interface{}) *MockDialer_Dial_Call

Dial is a helper method to define mock.On call

  • ctx context.Context
  • peer dndm.Peer
  • o ...DialOpt

func (*MockDialer_Expecter) Scheme

Scheme is a helper method to define mock.On call

type MockDialer_Scheme_Call

type MockDialer_Scheme_Call struct {
	*mock.Call
}

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

func (*MockDialer_Scheme_Call) Return

func (*MockDialer_Scheme_Call) Run

func (_c *MockDialer_Scheme_Call) Run(run func()) *MockDialer_Scheme_Call

func (*MockDialer_Scheme_Call) RunAndReturn

func (_c *MockDialer_Scheme_Call) RunAndReturn(run func() string) *MockDialer_Scheme_Call

type MockNode

type MockNode struct {
	mock.Mock
}

MockNode is an autogenerated mock type for the Node type

func NewMockNode

func NewMockNode(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockNode

NewMockNode creates a new instance of MockNode. 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 (*MockNode) Dial

func (_m *MockNode) Dial(ctx context.Context, peer dndm.Peer, o ...DialOpt) (io.ReadWriteCloser, error)

Dial provides a mock function with given fields: ctx, peer, o

func (*MockNode) EXPECT

func (_m *MockNode) EXPECT() *MockNode_Expecter

func (*MockNode) Scheme

func (_m *MockNode) Scheme() string

Scheme provides a mock function with given fields:

func (*MockNode) Serve

func (_m *MockNode) Serve(ctx context.Context, onConnect func(dndm.Peer, io.ReadWriteCloser) error, o ...SrvOpt) error

Serve provides a mock function with given fields: ctx, onConnect, o

type MockNode_Dial_Call

type MockNode_Dial_Call struct {
	*mock.Call
}

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

func (*MockNode_Dial_Call) Return

func (*MockNode_Dial_Call) Run

func (_c *MockNode_Dial_Call) Run(run func(ctx context.Context, peer dndm.Peer, o ...DialOpt)) *MockNode_Dial_Call

func (*MockNode_Dial_Call) RunAndReturn

type MockNode_Expecter

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

func (*MockNode_Expecter) Dial

func (_e *MockNode_Expecter) Dial(ctx interface{}, peer interface{}, o ...interface{}) *MockNode_Dial_Call

Dial is a helper method to define mock.On call

  • ctx context.Context
  • peer dndm.Peer
  • o ...DialOpt

func (*MockNode_Expecter) Scheme

Scheme is a helper method to define mock.On call

func (*MockNode_Expecter) Serve

func (_e *MockNode_Expecter) Serve(ctx interface{}, onConnect interface{}, o ...interface{}) *MockNode_Serve_Call

Serve is a helper method to define mock.On call

  • ctx context.Context
  • onConnect func(dndm.Peer , io.ReadWriteCloser) error
  • o ...SrvOpt

type MockNode_Scheme_Call

type MockNode_Scheme_Call struct {
	*mock.Call
}

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

func (*MockNode_Scheme_Call) Return

func (*MockNode_Scheme_Call) Run

func (_c *MockNode_Scheme_Call) Run(run func()) *MockNode_Scheme_Call

func (*MockNode_Scheme_Call) RunAndReturn

func (_c *MockNode_Scheme_Call) RunAndReturn(run func() string) *MockNode_Scheme_Call

type MockNode_Serve_Call

type MockNode_Serve_Call struct {
	*mock.Call
}

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

func (*MockNode_Serve_Call) Return

func (*MockNode_Serve_Call) Run

func (_c *MockNode_Serve_Call) Run(run func(ctx context.Context, onConnect func(dndm.Peer, io.ReadWriteCloser) error, o ...SrvOpt)) *MockNode_Serve_Call

func (*MockNode_Serve_Call) RunAndReturn

type MockServer

type MockServer struct {
	mock.Mock
}

MockServer is an autogenerated mock type for the Server type

func NewMockServer

func NewMockServer(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockServer

NewMockServer creates a new instance of MockServer. 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 (*MockServer) EXPECT

func (_m *MockServer) EXPECT() *MockServer_Expecter

func (*MockServer) Serve

func (_m *MockServer) Serve(ctx context.Context, onConnect func(dndm.Peer, io.ReadWriteCloser) error, o ...SrvOpt) error

Serve provides a mock function with given fields: ctx, onConnect, o

type MockServer_Expecter

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

func (*MockServer_Expecter) Serve

func (_e *MockServer_Expecter) Serve(ctx interface{}, onConnect interface{}, o ...interface{}) *MockServer_Serve_Call

Serve is a helper method to define mock.On call

  • ctx context.Context
  • onConnect func(dndm.Peer , io.ReadWriteCloser) error
  • o ...SrvOpt

type MockServer_Serve_Call

type MockServer_Serve_Call struct {
	*mock.Call
}

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

func (*MockServer_Serve_Call) Return

func (*MockServer_Serve_Call) Run

func (_c *MockServer_Serve_Call) Run(run func(ctx context.Context, onConnect func(dndm.Peer, io.ReadWriteCloser) error, o ...SrvOpt)) *MockServer_Serve_Call

func (*MockServer_Serve_Call) RunAndReturn

type Node

type Node interface {
	Dialer
	Server
}

Node interface describes both a dialer and a server.

type Server

type Server interface {
	Serve(ctx context.Context, onConnect func(peer dndm.Peer, r io.ReadWriteCloser) error, o ...SrvOpt) error
}

Server interface describes objects that can listen for connections.

type SrvOpt

type SrvOpt func(*SrvOptStruct) error

type SrvOptStruct

type SrvOptStruct struct {
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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