Documentation
¶
Index ¶
- Constants
- Variables
- type CounterStorage
- type Handler
- type IntLimits
- type LogonSettings
- type LogonState
- type MessageBuilders
- type MessageStorage
- type Opts
- type Session
- func (s *Session) Context() context.Context
- func (s *Session) CurrentTime() time.Time
- func (s *Session) HandlerError(err error)
- func (s *Session) IsLogged() bool
- func (s *Session) LogonRequest() error
- func (s *Session) Logout() error
- func (s *Session) MakeReject(reasonCode, tag, seqNum int) messages.RejectBuilder
- func (s *Session) OnChangeState(event utils.Event, handle utils.EventHandlerFunc)
- func (s *Session) OnError(handler func(error))
- func (s *Session) RejectMessage(msg []byte)
- func (s *Session) Run() (err error)
- func (s *Session) Send(msg messages.Message) error
- func (s *Session) SetLogonRequest(logonRequest func(*Session) error)
- func (s *Session) SetUnmarshaller(unmarshaller Unmarshaller)
- func (s *Session) StartWaiting()
- func (s *Session) Stop() (err error)
- type Side
- type Unmarshaller
Constants ¶
const (
MinLogonTimeout = time.Millisecond
)
Variables ¶
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 ¶
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
Stop()
}
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
ResetSeqNumFlag bool
}
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 // WaitingTestReqAnswer waiting for a response to a Test request before disconnect WaitingTestReqAnswer // Disconnect need to disconnect session Disconnect )
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
SequenceResetBuilder messages.SequenceResetBuilder
ExecutionReportBuilder messages.ExecutionReportBuilder
NewOrderSingleBuilder messages.NewOrderSingleBuilder
MarketDataRequestBuilder messages.MarketDataRequestBuilder
OrderCancelRequestBuilder messages.OrderCancelRequestBuilder
}
type MessageStorage ¶
type MessageStorage interface {
Save(storageID fix.StorageID, msg simplefixgo.SendingMessage, msgSeqNum int) error
Messages(storageID fix.StorageID, 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) CurrentTime ¶
func (*Session) HandlerError ¶
func (*Session) LogonRequest ¶
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 ¶
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 (*Session) Send ¶
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 (*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()