protocol

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServerClosed = errors.New("server closed")

ErrServerClosed is the error that the server is already closed.

Functions

func All

func All() map[string]Protocol

All returns all registered protocol.

func Register

func Register(p Protocol)

Register registers the protocol to the registry.

func Unregister

func Unregister(name string)

Unregister unregisters the protocol from the registry.

Types

type Mock

type Mock struct {
	Protocol string              `yaml:"protocol"`
	Expect   yamlutil.RawMessage `yaml:"expect"`
	Response yamlutil.RawMessage `yaml:"response"`
}

Mock represents a mock.

type MockIterator

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

MockIterator is an iterator over Mocks.

func NewMockIterator

func NewMockIterator(mocks []Mock) *MockIterator

New returns a new MockIterator.

func (*MockIterator) Next

func (i *MockIterator) Next() (*Mock, error)

Next returns the next mock.

func (*MockIterator) Stop

func (i *MockIterator) Stop() error

Stop terminates the iteration. It should be called after you finish using the iterator. If mocks not consumed remain returns a MocksRemainError.

type MocksRemainError

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

MocksRemainError is the error returned by Stop when mocks not consumed remain.

func (*MocksRemainError) Error

func (e *MocksRemainError) Error() string

Error implements error interface.

type Protocol

type Protocol interface {
	Name() string
	UnmarshalConfig([]byte) (interface{}, error)
	NewServer(iter *MockIterator, l logger.Logger, config interface{}) (Server, error)
}

Protocol is the interface that creates mock server.

func Get

func Get(name string) Protocol

Get returns the protocol registered with the given name.

type Server

type Server interface {
	Start(context.Context) error
	Wait(context.Context) error
	Stop(context.Context) error
	Addr() (string, error)
}

Server represents a mock server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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