session

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinLogonTimeout = time.Millisecond
)

Variables

View Source
var (
	ErrMissingHandler          = errors.New("a handler is missing")
	ErrMissingRequiredTag      = errors.New("a required tag is missing in the tags list")
	ErrMissingEncryptedMethods = errors.New("a list of supported encryption methods is missing")
	ErrMissingErrorCodes       = errors.New("a list of error codes is missing")
	ErrMissingMessageBuilder   = errors.New("a required message builder is missing")
	ErrInvalidHeartBtLimits    = errors.New("an invalid heartbeat value exceeding the allowed limit")
	ErrInvalidHeartBtInt       = errors.New("an invalid integer value assigned to the heartbeat field")
	ErrInvalidLogonTimeout     = errors.New("the logon request timeout is too small")
	ErrMissingEncryptMethod    = errors.New("the encryption method is missing") // done
	ErrMissingLogonSettings    = errors.New("logon settings are missing")       // done
	ErrMissingSessionOts       = errors.New("session options are missing")      // done
)

Functions

This section is empty.

Types

type CounterStorage added in v1.10.0

type CounterStorage interface {
	GetNextSeqNum(pk string) (int, error)
	GetCurrSeqNum(pk string) (int, error)
	ResetSeqNum(pk string) error
}

type Handler

type Handler interface {
	HandleIncoming(msgType string, handle simplefixgo.IncomingHandlerFunc) (id int64)
	HandleOutgoing(msgType string, handle simplefixgo.OutgoingHandlerFunc) (id int64)
	RemoveIncomingHandler(msgType string, id int64) (err error)
	RemoveOutgoingHandler(msgType string, id int64) (err error)
	SendRaw(data []byte) error
	Send(message simplefixgo.SendingMessage) error
	SendBatch(messages []simplefixgo.SendingMessage) error
	Context() context.Context
}

type IntLimits

type IntLimits struct {
	Min int
	Max int
}

todo

type LogonSettings

type LogonSettings struct {
	TargetCompID  string
	SenderCompID  string
	HeartBtInt    int
	EncryptMethod string
	Password      string
	Username      string
	LogonTimeout  time.Duration // todo
	HeartBtLimits *IntLimits
	CloseTimeout  time.Duration
}

TODO: constructor for acceptor and initiator

type LogonState

type LogonState int64
const (
	// WaitingLogon the connection has just started, waiting for a Session message or preparing to send it.
	WaitingLogon LogonState = iota

	// SuccessfulLogged session participants are authenticated, ready to work.
	SuccessfulLogged

	// WaitingLogonAnswer waiting for a response to a Logon message before starting the session.
	WaitingLogonAnswer

	// WaitingLogoutAnswer waiting for a response to a Logout message before terminating the session.
	WaitingLogoutAnswer

	// ReceivedLogoutAnswer a response to a Logout message was received.
	ReceivedLogoutAnswer
)

type MessageBuilders

type MessageBuilders struct {
	HeaderBuilder        messages.HeaderBuilder
	TrailerBuilder       messages.TrailerBuilder
	LogonBuilder         messages.LogonBuilder
	LogoutBuilder        messages.LogoutBuilder
	RejectBuilder        messages.RejectBuilder
	HeartbeatBuilder     messages.HeartbeatBuilder
	TestRequestBuilder   messages.TestRequestBuilder
	ResendRequestBuilder messages.ResendRequestBuilder
}

type MessageStorage

type MessageStorage interface {
	Save(pk string, msg simplefixgo.SendingMessage, msgSeqNum int) error
	Messages(pk string, msgSeqNumFrom, msgSeqNumTo int) ([]simplefixgo.SendingMessage, error)
}

MessageStorage is an interface providing a basic method for storing messages awaiting to be sent.

type Opts

type Opts struct {
	Location                string
	MessageBuilders         MessageBuilders
	Tags                    *messages.Tags
	AllowedEncryptedMethods map[string]struct{} // Can only be of the "None" type.
	SessionErrorCodes       *messages.SessionErrorCodes
}

Opts is a structure providing auto-generated Session options.

type Session

type Session struct {
	*Opts

	// Services:
	Router Handler

	// Parameters:
	LogonHandler  logonHandler
	LogonSettings *LogonSettings
	// contains filtered or unexported fields
}

Session is a service that is used to maintain the default FIX API pipelines, which include the logon, logout and heartbeat messages, as well as rejects and message sequences.

func NewAcceptorSession

func NewAcceptorSession(params *Opts, handler Handler, settings *LogonSettings, onLogon logonHandler, cs CounterStorage, ms MessageStorage) (s *Session, err error)

NewAcceptorSession returns a session for an Acceptor object.

func NewInitiatorSession

func NewInitiatorSession(handler Handler, opts *Opts, settings *LogonSettings, cs CounterStorage, ms MessageStorage) (s *Session, err error)

NewInitiatorSession returns a session for an Initiator object.

func (*Session) Context

func (s *Session) Context() context.Context

func (*Session) CurrentTime

func (s *Session) CurrentTime() time.Time

func (*Session) HandlerError

func (s *Session) HandlerError(err error)

func (*Session) IsLogged

func (s *Session) IsLogged() bool

func (*Session) LogonRequest

func (s *Session) LogonRequest() error

func (*Session) Logout

func (s *Session) Logout() error

func (*Session) MakeReject

func (s *Session) MakeReject(reasonCode, tag, seqNum int) messages.RejectBuilder

func (*Session) OnChangeState

func (s *Session) OnChangeState(event utils.Event, handle utils.EventHandlerFunc)

func (*Session) OnError

func (s *Session) OnError(handler func(error))

OnError is called when something goes wrong but the connection is still working. You can use it for handling errors that might occur as part of standard session procedures.

func (*Session) RejectMessage

func (s *Session) RejectMessage(msg []byte)

func (*Session) Run

func (s *Session) Run() (err error)

func (*Session) Send

func (s *Session) Send(msg messages.Message) error

Send is used to send a message after preparing its header tags: - the sequence number with a counter - the targetCompID and senderCompID fields - the sending time, with the current time zone indicated To send a message with custom fields, call the Send method for a Handler instead.

func (*Session) SetLogonRequest

func (s *Session) SetLogonRequest(logonRequest func(*Session) error)

func (*Session) SetUnmarshaller

func (s *Session) SetUnmarshaller(unmarshaller Unmarshaller)

SetUnmarshaller replaces current unmarshaller buy custom one It could be called only before starting Session

func (*Session) StartWaiting

func (s *Session) StartWaiting()

func (*Session) Stop

func (s *Session) Stop() (err error)

type Side

type Side int64

type Unmarshaller

type Unmarshaller interface {
	Unmarshal(msg messages.Builder, d []byte) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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