Documentation
¶
Overview ¶
Package gofix is a full featured messaging engine for the FIX protocol. It is based on the open source QuickFIX/Go engine, with some performance improvements and breaking API changes from the original library. The original QuickFIX/Go library is a 100% Go open source implementation of the popular C++ QuickFIX engine (http://quickfixengine.org).
Warning ¶
gofix is an experimental fork built for Appital's own use. We do not support it for any other use. Its API and behaviour may change without notice, and we do not plan to accept outside feature requests or provide help with integration. For most projects we strongly recommend the upstream QuickFIX/Go library instead.
The QuickFIX/Go user manual at https://quickfixengine.org/go/documentation/ still covers most configuration and concepts. Where gofix differs, see CHANGELOG.md and the config package.
Index ¶
- Constants
- Variables
- func GetExpectedSenderNum(sessionID SessionID) (int, error)
- func GetExpectedTargetNum(sessionID SessionID) (int, error)
- func ParseMessage(msg *Message, rawMessage *bytes.Buffer) (err error)
- func ParseMessageWithDataDictionary(msg *Message, rawMessage *bytes.Buffer, ...) (err error)
- func ResetSession(sessionID SessionID) error
- func Send(m Messagable) (err error)
- func SendToTarget(m Messagable, sessionID SessionID) error
- func SetNextSenderMsgSeqNum(sessionID SessionID, seqNum int) error
- func SetNextTargetMsgSeqNum(sessionID SessionID, seqNum int) error
- func UnregisterSession(sessionID SessionID) error
- type Acceptor
- func (a *Acceptor) Registry() *Registry
- func (a *Acceptor) RemoteAddr(sessionID SessionID) (net.Addr, bool)
- func (a *Acceptor) SetConnectionValidator(validator ConnectionValidator)
- func (a *Acceptor) SetNewListenerCallback(cb NewListenerCallback)
- func (a *Acceptor) SetTLSConfig(tlsConfig *tls.Config)
- func (a *Acceptor) Start() (err error)
- func (a *Acceptor) Stop()
- type Application
- type Body
- type ConditionallyRequiredSetting
- type ConnectionValidator
- type FIXBoolean
- type FIXBytes
- type FIXDecimal
- type FIXFloat
- type FIXInt
- type FIXString
- type FIXUDecimal
- type FIXUTCTimestamp
- type Field
- type FieldGroup
- type FieldGroupReader
- type FieldGroupWriter
- type FieldMap
- func (m *FieldMap) Clear()
- func (m *FieldMap) CopyInto(to *FieldMap)
- func (m FieldMap) Get(parser Field) MessageRejectError
- func (m FieldMap) GetBool(tag Tag) (bool, MessageRejectError)
- func (m FieldMap) GetBytes(tag Tag) ([]byte, MessageRejectError)
- func (m FieldMap) GetField(tag Tag, parser FieldValueReader) MessageRejectError
- func (m FieldMap) GetGroup(parser FieldGroupReader) MessageRejectError
- func (m FieldMap) GetInt(tag Tag) (int, MessageRejectError)
- func (m FieldMap) GetString(tag Tag) (string, MessageRejectError)
- func (m FieldMap) GetTime(tag Tag) (t time.Time, err MessageRejectError)
- func (m FieldMap) Has(tag Tag) bool
- func (t FieldMap) Len() int
- func (t FieldMap) Less(i, j int) bool
- func (m *FieldMap) Remove(tag Tag)
- func (m *FieldMap) Set(field FieldWriter) *FieldMap
- func (m *FieldMap) SetBool(tag Tag, value bool) *FieldMap
- func (m *FieldMap) SetBytes(tag Tag, value []byte) *FieldMap
- func (m *FieldMap) SetField(tag Tag, field FieldValueWriter) *FieldMap
- func (m *FieldMap) SetGroup(field FieldGroupWriter) *FieldMap
- func (m *FieldMap) SetInt(tag Tag, value int) *FieldMap
- func (m *FieldMap) SetString(tag Tag, value string) *FieldMap
- func (t FieldMap) Swap(i, j int)
- func (m FieldMap) Tags() []Tag
- type FieldValue
- type FieldValueReader
- type FieldValueWriter
- type FieldWriter
- type FromAdminInterceptor
- type Group
- type GroupItem
- type GroupTemplate
- type Header
- type IncorrectFormatForSetting
- type Initiator
- type Log
- type LogFactory
- type Messagable
- type Message
- type MessageInterceptor
- type MessageRejectError
- func ConditionallyRequiredFieldMissing(tag Tag) MessageRejectError
- func IncorrectDataFormatForValue(tag Tag) MessageRejectError
- func InvalidMessageType() MessageRejectError
- func InvalidTagNumber(tag Tag) MessageRejectError
- func NewBusinessMessageRejectError(err string, rejectReason int, refTagID *Tag) MessageRejectError
- func NewBusinessMessageRejectErrorWithRefID(err string, rejectReason int, businessRejectRefID string, refTagID *Tag) MessageRejectError
- func NewMessageRejectError(err string, rejectReason int, refTagID *Tag) MessageRejectError
- func RequiredTagMissing(tag Tag) MessageRejectError
- func TagNotDefinedForThisMessageType(tag Tag) MessageRejectError
- func TagSpecifiedWithoutAValue(tag Tag) MessageRejectError
- func UnsupportedMessageType() MessageRejectError
- func ValueIsIncorrect(tag Tag) MessageRejectError
- type MessageRoute
- type MessageRouter
- type MessageStore
- type MessageStoreFactory
- type Metrics
- type MetricsFactory
- type NewListenerCallback
- type OnCreateHandler
- type OnLogonHandler
- type OnLogoutHandler
- type Option
- type Registry
- func (r *Registry) GetExpectedSenderNum(sessionID SessionID) (int, error)
- func (r *Registry) GetExpectedTargetNum(sessionID SessionID) (int, error)
- func (r *Registry) GetLog(sessionID SessionID) (Log, error)
- func (r *Registry) GetMessageStore(sessionID SessionID) (MessageStore, error)
- func (r *Registry) ResetSession(sessionID SessionID) error
- func (r *Registry) Send(m Messagable) (err error)
- func (r *Registry) SendToTarget(m Messagable, sessionID SessionID) error
- func (r *Registry) SetNextSenderMsgSeqNum(sessionID SessionID, seqNum int) error
- func (r *Registry) SetNextTargetMsgSeqNum(sessionID SessionID, seqNum int) error
- func (r *Registry) UnregisterSession(sessionID SessionID) error
- type RejectLogon
- type RepeatingGroup
- func (f *RepeatingGroup) Add() *Group
- func (f RepeatingGroup) Clone() GroupItem
- func (f RepeatingGroup) Get(i int) *Group
- func (f RepeatingGroup) Len() int
- func (f *RepeatingGroup) Read(tv []TagValue) ([]TagValue, error)
- func (f *RepeatingGroup) Reset()
- func (f RepeatingGroup) Tag() Tag
- func (f RepeatingGroup) Write() []TagValue
- type SessionHandler
- type SessionID
- type SessionSettings
- func (s SessionSettings) BoolSetting(setting string) (bool, error)
- func (s *SessionSettings) DurationSetting(setting string) (time.Duration, error)
- func (s *SessionSettings) HasSetting(setting string) bool
- func (s *SessionSettings) Init()
- func (s *SessionSettings) IntSetting(setting string) (int, error)
- func (s *SessionSettings) RawSetting(setting string) ([]byte, error)
- func (s *SessionSettings) Set(setting string, val string)
- func (s *SessionSettings) SetRaw(setting string, val []byte)
- func (s *SessionSettings) Setting(setting string) (string, error)
- type Settings
- type Tag
- type TagValue
- type TimestampPrecision
- type ToAdminInterceptor
- type ToAppInterceptor
- type Trailer
- type Validator
- type ValidatorSettings
Constants ¶
const ( BeginStringFIX40 = "FIX.4.0" BeginStringFIX41 = "FIX.4.1" BeginStringFIX42 = "FIX.4.2" BeginStringFIX43 = "FIX.4.3" BeginStringFIX44 = "FIX.4.4" BeginStringFIXT11 = "FIXT.1.1" )
FIX BeginString string values.
const ( ApplVerIDFIX27 = "0" ApplVerIDFIX30 = "1" ApplVerIDFIX40 = "2" ApplVerIDFIX41 = "3" ApplVerIDFIX42 = "4" ApplVerIDFIX43 = "5" ApplVerIDFIX44 = "6" ApplVerIDFIX50 = "7" ApplVerIDFIX50SP1 = "8" ApplVerIDFIX50SP2 = "9" )
FIX ApplVerID string values.
const (
UserDefinedTagMin int = 5000
)
Variables ¶
var ErrDoNotSend = errors.New("Do Not Send") //nolint:staticcheck // ST1005: exported message kept for compatibility.
ErrDoNotSend is a convenience error to indicate a DoNotSend in ToApp.
Functions ¶
func GetExpectedSenderNum ¶
GetExpectedSenderNum retrieves the expected sender sequence number for the session matching the session id. It uses the DefaultRegistry.
func GetExpectedTargetNum ¶
GetExpectedTargetNum retrieves the next target sequence number for the session matching the session id. It uses the DefaultRegistry.
func ParseMessage ¶
ParseMessage constructs a Message from a byte slice wrapping a FIX message.
func ParseMessageWithDataDictionary ¶
func ParseMessageWithDataDictionary( msg *Message, rawMessage *bytes.Buffer, transportDataDictionary *datadictionary.DataDictionary, appDataDictionary *datadictionary.DataDictionary, ) (err error)
ParseMessageWithDataDictionary constructs a Message from a byte slice wrapping a FIX message using an optional session and application DataDictionary for reference.
func ResetSession ¶
ResetSession resets session's sequence numbers. It uses the DefaultRegistry.
func Send ¶
func Send(m Messagable) (err error)
Send determines the session to send Messagable using header fields BeginString, TargetCompID, SenderCompID. It uses the DefaultRegistry.
func SendToTarget ¶
func SendToTarget(m Messagable, sessionID SessionID) error
SendToTarget sends a message based on the sessionID. Convenient for use in FromApp since it provides a session ID for incoming messages. It uses the DefaultRegistry.
func SetNextSenderMsgSeqNum ¶
SetNextSenderMsgSeqNum sets the next outgoing message sequence number for the session matching the session id. It uses the DefaultRegistry.
func SetNextTargetMsgSeqNum ¶
SetNextTargetMsgSeqNum set the next expected target message sequence number for the session matching the session id. It uses the DefaultRegistry.
func UnregisterSession ¶
UnregisterSession removes a session from the set of known sessions. It uses the DefaultRegistry.
Types ¶
type Acceptor ¶
type Acceptor struct {
// contains filtered or unexported fields
}
Acceptor accepts connections from FIX clients and manages the associated sessions.
func NewAcceptor ¶
func NewAcceptor(app Application, storeFactory MessageStoreFactory, settings *Settings, logFactory LogFactory, opts ...Option) (a *Acceptor, err error)
NewAcceptor creates and initializes a new Acceptor. It returns an error if app has an optional callback method that would never be called; see Application.
func (*Acceptor) Registry ¶
Registry returns the Registry the Acceptor's sessions are registered in.
func (*Acceptor) RemoteAddr ¶
RemoteAddr gets remote IP address for a given session.
func (*Acceptor) SetConnectionValidator ¶
func (a *Acceptor) SetConnectionValidator(validator ConnectionValidator)
SetConnectionValidator sets an optional connection validator. Use it when you need a custom authentication logic that includes lower level interactions, like mTLS auth or IP whitelistening. To remove a previously set validator call it with a nil value:
a.SetConnectionValidator(nil)
func (*Acceptor) SetNewListenerCallback ¶
func (a *Acceptor) SetNewListenerCallback(cb NewListenerCallback)
SetNewListenerCallback allows the creator of the Acceptor to specify the callback used to create each net.Listener which will be used in the Start() method.
func (*Acceptor) SetTLSConfig ¶
SetTLSConfig allows the creator of the Acceptor to specify a fully customizable tls.Config of their choice, which will be used in the Start() method.
Note: when the caller explicitly provides a tls.Config with this function, it takes precendent over TLS settings specified in the acceptor's settings.GlobalSettings(), meaning that the `settings.GlobalSettings()` object is not inspected or used for the creation of the tls.Config.
type Application ¶
type Application interface {
// FromApp notification of app message being received from target.
FromApp(message *Message, sessionID SessionID) MessageRejectError
}
Application is implemented by FIX applications to receive application messages from a session. FromApp is the only callback an application must implement.
An Application may also implement any of the other callbacks: those in SessionHandler, to be told about session lifecycle events, and those in MessageInterceptor, to inspect, modify or veto messages as they cross the session. Each callback has its own interface, such as FromAdminInterceptor, so an application can implement only the ones it needs. The engine checks for them once, when it creates each session. Leaving one out has the same effect as implementing it with an empty method: inbound admin messages are accepted and every send goes ahead.
NewAcceptor and NewInitiator return an error if the application has a method named after one of these callbacks whose signature does not match, since the engine would never call it. For example, an acceptor that authenticates Logons in FromAdmin, but declares FromAdmin to return error instead of MessageRejectError, would otherwise accept every Logon without checking it. A compile-time assertion for each interface the application is meant to implement catches the same mistake earlier:
var ( _ gofix.Application = (*myApp)(nil) _ gofix.SessionHandler = (*myApp)(nil) _ gofix.FromAdminInterceptor = (*myApp)(nil) )
type ConditionallyRequiredSetting ¶
type ConditionallyRequiredSetting struct {
Setting string
}
ConditionallyRequiredSetting indicates a missing setting.
func (ConditionallyRequiredSetting) Error ¶
func (e ConditionallyRequiredSetting) Error() string
type ConnectionValidator ¶
type ConnectionValidator interface {
// Validate the connection for validity. This can be a part of authentication process.
// For example, you may tie up a SenderCompID to an IP range, or to a specific TLS certificate as a part of mTLS.
Validate(netConn net.Conn, session SessionID) error
}
ConnectionValidator is an interface allowing to implement a custom authentication logic.
type FIXBoolean ¶
type FIXBoolean bool
FIXBoolean is a FIX Boolean value, implements FieldValue.
func (FIXBoolean) Bool ¶
func (f FIXBoolean) Bool() bool
Bool converts the FIXBoolean value to bool.
func (*FIXBoolean) Read ¶
func (f *FIXBoolean) Read(bytes []byte) error
func (FIXBoolean) Write ¶
func (f FIXBoolean) Write() []byte
type FIXBytes ¶
type FIXBytes []byte
FIXBytes is a generic FIX field value, implements FieldValue. Enables zero copy read from a FieldMap.
type FIXDecimal ¶
type FIXDecimal struct {
decimal.Decimal
// Scale is the number of digits after the decimal point when Writing the field value as a FIX value.
Scale int32
}
FIXDecimal is a FIX Float Value that implements an arbitrary precision fixed-point decimal. Implements FieldValue.
func (*FIXDecimal) Read ¶
func (d *FIXDecimal) Read(bytes []byte) (err error)
func (FIXDecimal) Write ¶
func (d FIXDecimal) Write() []byte
type FIXFloat ¶
type FIXFloat float64
FIXFloat is a FIX Float Value, implements FieldValue.
type FIXUDecimal ¶
type FIXUDecimal struct {
udecimal.Decimal
// Scale is the number of digits after the decimal point when Writing the field value as a FIX value.
Scale uint8
}
FIXUDecimal is a FIX Float Value that implements an arbitrary precision fixed-point udecimal. Implements FieldValue.
func (*FIXUDecimal) Read ¶
func (d *FIXUDecimal) Read(bytes []byte) (err error)
func (FIXUDecimal) Write ¶
func (d FIXUDecimal) Write() []byte
type FIXUTCTimestamp ¶
type FIXUTCTimestamp struct {
time.Time
Precision TimestampPrecision
}
FIXUTCTimestamp is a FIX UTC Timestamp value, implements FieldValue.
func (*FIXUTCTimestamp) Read ¶
func (f *FIXUTCTimestamp) Read(bytes []byte) (err error)
func (FIXUTCTimestamp) Write ¶
func (f FIXUTCTimestamp) Write() []byte
type Field ¶
type Field interface {
FieldWriter
FieldValueReader
}
Field is the interface implemented by all typed Fields in a Message.
type FieldGroup ¶
FieldGroup is the interface implemented by all typed Groups in a Message.
type FieldGroupReader ¶
FieldGroupReader is an interface for reading a FieldGroup.
type FieldGroupWriter ¶
FieldGroupWriter is an interface for writing a FieldGroup.
type FieldMap ¶
type FieldMap struct {
// contains filtered or unexported fields
}
FieldMap is a collection of fix fields that make up a fix message.
func (FieldMap) Get ¶
func (m FieldMap) Get(parser Field) MessageRejectError
Get parses out a field in this FieldMap. Returned reject may indicate the field is not present, or the field value is invalid.
func (FieldMap) GetBool ¶
func (m FieldMap) GetBool(tag Tag) (bool, MessageRejectError)
GetBool is a GetField wrapper for bool fields.
func (FieldMap) GetBytes ¶
func (m FieldMap) GetBytes(tag Tag) ([]byte, MessageRejectError)
GetBytes is a zero-copy GetField wrapper for []bytes fields.
func (FieldMap) GetField ¶
func (m FieldMap) GetField(tag Tag, parser FieldValueReader) MessageRejectError
GetField parses of a field with Tag tag. Returned reject may indicate the field is not present, or the field value is invalid.
func (FieldMap) GetGroup ¶
func (m FieldMap) GetGroup(parser FieldGroupReader) MessageRejectError
GetGroup is a Get function specific to Group Fields.
func (FieldMap) GetInt ¶
func (m FieldMap) GetInt(tag Tag) (int, MessageRejectError)
GetInt is a GetField wrapper for int fields.
func (FieldMap) GetString ¶
func (m FieldMap) GetString(tag Tag) (string, MessageRejectError)
GetString is a GetField wrapper for string fields.
func (FieldMap) GetTime ¶
func (m FieldMap) GetTime(tag Tag) (t time.Time, err MessageRejectError)
GetTime is a GetField wrapper for utc timestamp fields.
func (*FieldMap) Set ¶
func (m *FieldMap) Set(field FieldWriter) *FieldMap
Set is a setter for fields.
func (*FieldMap) SetField ¶
func (m *FieldMap) SetField(tag Tag, field FieldValueWriter) *FieldMap
SetField sets the field with Tag tag.
func (*FieldMap) SetGroup ¶
func (m *FieldMap) SetGroup(field FieldGroupWriter) *FieldMap
SetGroup is a setter specific to group fields.
type FieldValue ¶
type FieldValue interface {
FieldValueWriter
FieldValueReader
}
The FieldValue interface is used to write/extract typed field values to/from raw bytes.
type FieldValueReader ¶
type FieldValueReader interface {
// Read reads the contents of the `[]byte` into FieldValue.
// Returns an error if there are issues in the data processing.
Read([]byte) error
}
FieldValueReader is an interface for reading field values.
type FieldValueWriter ¶
type FieldValueWriter interface {
// Write writes out the contents of the FieldValue to a `[]byte`.
Write() []byte
}
FieldValueWriter is an interface for writing field values.
type FieldWriter ¶
type FieldWriter interface {
Tag() Tag
FieldValueWriter
}
FieldWriter is an interface for a writing a field.
type FromAdminInterceptor ¶ added in v0.4.0
type FromAdminInterceptor interface {
// FromAdmin notification of admin message being received from target.
// Returning a MessageRejectError rejects the message; for a Logon, this
// refuses the logon.
FromAdmin(message *Message, sessionID SessionID) MessageRejectError
}
FromAdminInterceptor is implemented by an Application that wants to see, or reject, admin messages as they are received, for example to authenticate Logons. It is optional; see Application.
type Group ¶
type Group struct{ FieldMap }
Group is a group of fields occurring in a repeating group.
type GroupItem ¶
type GroupItem interface {
// Tag returns the tag identifying this GroupItem.
Tag() Tag
// Read Parameter to Read is tagValues. For most fields, only the first tagValue will be required.
// The length of the slice extends from the tagValue mapped to the field to be read through the
// following fields. This can be useful for GroupItems made up of repeating groups.
//
// The Read function returns the remaining tagValues not processed by the GroupItem. If there was a
// problem reading the field, an error may be returned.
Read([]TagValue) ([]TagValue, error)
// Clone makes a copy of this GroupItem.
Clone() GroupItem
}
GroupItem interface is used to construct repeating group templates.
func GroupElement ¶
GroupElement returns a GroupItem made up of a single field.
type GroupTemplate ¶
type GroupTemplate []GroupItem
GroupTemplate specifies the group item order for a RepeatingGroup.
func (GroupTemplate) Clone ¶
func (gt GroupTemplate) Clone() GroupTemplate
Clone makes a copy of this GroupTemplate.
type IncorrectFormatForSetting ¶
IncorrectFormatForSetting indicates a setting that is incorrectly formatted.
func (IncorrectFormatForSetting) Error ¶
func (e IncorrectFormatForSetting) Error() string
type Initiator ¶
type Initiator struct {
// contains filtered or unexported fields
}
Initiator initiates connections and processes messages for all sessions.
func NewInitiator ¶
func NewInitiator(app Application, storeFactory MessageStoreFactory, appSettings *Settings, logFactory LogFactory, opts ...Option) (*Initiator, error)
NewInitiator creates and initializes a new Initiator. It returns an error if app has an optional callback method that would never be called; see Application.
type Log ¶
type Log interface {
// OnIncoming log incoming fix message.
OnIncoming([]byte)
// OnOutgoing log outgoing fix message.
OnOutgoing([]byte)
// OnEvent log fix event.
OnEvent(string)
// OnEventf log fix event according to format specifier.
OnEventf(string, ...any)
}
Log is a generic interface for logging FIX messages and events.
type LogFactory ¶
type LogFactory interface {
// Create global log.
Create() (Log, error)
// CreateSessionLog session specific log.
CreateSessionLog(sessionID SessionID) (Log, error)
}
The LogFactory interface creates global and session specific Log instances.
func NewNullLogFactory ¶
func NewNullLogFactory() LogFactory
NewNullLogFactory creates an instance of LogFactory that returns no-op loggers.
type Messagable ¶
type Messagable interface {
ToMessage() *Message
}
Messagable is a Message or something that can be converted to a Message.
type Message ¶
type Message struct {
Header Header
Trailer Trailer
Body Body
// ReceiveTime is the time that this message was read from the socket connection.
ReceiveTime time.Time
// contains filtered or unexported fields
}
Message is a FIX Message abstraction.
func NewMessage ¶
func NewMessage() *Message
NewMessage returns a newly initialized Message instance.
func (*Message) CopyInto ¶
CopyInto erases the dest messages and copies the currency message content into it.
func (*Message) IsMsgTypeOf ¶
IsMsgTypeOf returns true if the Header contains MsgType (tag 35) field and its value is the specified one.
func (*Message) MsgType ¶
func (m *Message) MsgType() (string, MessageRejectError)
MsgType returns MsgType (tag 35) field's value.
type MessageInterceptor ¶
type MessageInterceptor interface {
ToAdminInterceptor
FromAdminInterceptor
ToAppInterceptor
}
MessageInterceptor is implemented by an Application that wants to inspect, modify or veto messages as they cross the session: admin messages in both directions, and application messages being sent. It is optional; see Application.
type MessageRejectError ¶
type MessageRejectError interface {
error
// RejectReason, tag 373 for session rejects, tag 380 for business rejects.
RejectReason() int
BusinessRejectRefID() string
RefTagID() *Tag
IsBusinessReject() bool
}
MessageRejectError is a type of error that can correlate to a message reject.
func ConditionallyRequiredFieldMissing ¶
func ConditionallyRequiredFieldMissing(tag Tag) MessageRejectError
ConditionallyRequiredFieldMissing indicates that the requested field could not be found in the FIX message.
func IncorrectDataFormatForValue ¶
func IncorrectDataFormatForValue(tag Tag) MessageRejectError
IncorrectDataFormatForValue returns an error indicating a field that cannot be parsed as the type required.
func InvalidMessageType ¶
func InvalidMessageType() MessageRejectError
InvalidMessageType returns an error to indicate an invalid message type.
func InvalidTagNumber ¶
func InvalidTagNumber(tag Tag) MessageRejectError
InvalidTagNumber returns a validation error for messages with invalid tags.
func NewBusinessMessageRejectError ¶
func NewBusinessMessageRejectError(err string, rejectReason int, refTagID *Tag) MessageRejectError
NewBusinessMessageRejectError returns a MessageRejectError with the given error mesage, reject reason, and optional reftagid. Reject is treated as a business level reject.
func NewBusinessMessageRejectErrorWithRefID ¶
func NewBusinessMessageRejectErrorWithRefID(err string, rejectReason int, businessRejectRefID string, refTagID *Tag) MessageRejectError
NewBusinessMessageRejectErrorWithRefID returns a MessageRejectError with the given error mesage, reject reason, refID, and optional reftagid. Reject is treated as a business level reject.
func NewMessageRejectError ¶
func NewMessageRejectError(err string, rejectReason int, refTagID *Tag) MessageRejectError
NewMessageRejectError returns a MessageRejectError with the given error message, reject reason, and optional reftagid.
func RequiredTagMissing ¶
func RequiredTagMissing(tag Tag) MessageRejectError
RequiredTagMissing returns a validation error when a required field cannot be found in a message.
func TagNotDefinedForThisMessageType ¶
func TagNotDefinedForThisMessageType(tag Tag) MessageRejectError
TagNotDefinedForThisMessageType returns an error for an invalid tag appearing in a message.
func TagSpecifiedWithoutAValue ¶
func TagSpecifiedWithoutAValue(tag Tag) MessageRejectError
TagSpecifiedWithoutAValue returns a validation error for when a field has no value.
func UnsupportedMessageType ¶
func UnsupportedMessageType() MessageRejectError
UnsupportedMessageType returns an error to indicate an unhandled message.
func ValueIsIncorrect ¶
func ValueIsIncorrect(tag Tag) MessageRejectError
ValueIsIncorrect returns an error indicating a field with value that is not valid.
type MessageRoute ¶
type MessageRoute func(msg *Message, sessionID SessionID) MessageRejectError
A MessageRoute is a function that can process a fromApp/fromAdmin callback.
type MessageRouter ¶
type MessageRouter struct {
// contains filtered or unexported fields
}
A MessageRouter is a mutex for MessageRoutes. It implements Application, so it can be passed directly to NewAcceptor or NewInitiator.
func NewMessageRouter ¶
func NewMessageRouter(opts ...Option) *MessageRouter
NewMessageRouter returns an initialized MessageRouter instance. Pass WithRegistry when the router serves sessions registered in a Registry other than the DefaultRegistry.
func (MessageRouter) AddRoute ¶
func (c MessageRouter) AddRoute(beginString string, msgType string, router MessageRoute)
AddRoute adds a route to the MessageRouter instance keyed to begin string and msgType.
func (MessageRouter) FromApp ¶
func (c MessageRouter) FromApp(msg *Message, sessionID SessionID) MessageRejectError
FromApp routes an application message received from the counterparty. It makes MessageRouter an Application.
func (MessageRouter) Route ¶
func (c MessageRouter) Route(msg *Message, sessionID SessionID) MessageRejectError
Route may be called from the fromApp/fromAdmin callbacks. Messages that cannot be routed will be rejected with UnsupportedMessageType.
type MessageStore ¶
type MessageStore interface {
NextSenderMsgSeqNum() int
NextTargetMsgSeqNum() int
IncrNextSenderMsgSeqNum() error
IncrNextTargetMsgSeqNum() error
SetNextSenderMsgSeqNum(next int) error
SetNextTargetMsgSeqNum(next int) error
CreationTime() time.Time
SetCreationTime(time.Time)
SaveMessage(seqNum int, msg []byte) error
SaveMessageAndIncrNextSenderMsgSeqNum(seqNum int, msg []byte) error
GetMessages(beginSeqNum, endSeqNum int) ([][]byte, error)
IterateMessages(beginSeqNum, endSeqNum int, cb func([]byte) error) error
Refresh() error
Reset() error
Close() error
}
The MessageStore interface provides methods to record and retrieve messages for resend purposes.
func GetMessageStore ¶
func GetMessageStore(sessionID SessionID) (MessageStore, error)
GetMessageStore returns the MessageStore interface for session matching the session id. It uses the DefaultRegistry.
type MessageStoreFactory ¶
type MessageStoreFactory interface {
Create(sessionID SessionID) (MessageStore, error)
}
The MessageStoreFactory interface is used by session to create a session specific message store.
func NewMemoryStoreFactory ¶
func NewMemoryStoreFactory() MessageStoreFactory
NewMemoryStoreFactory returns a MessageStoreFactory instance that created in-memory MessageStores.
type Metrics ¶
type Metrics interface {
// MessageSent is called for each message the write loop writes, with its
// length in bytes.
MessageSent(bytes int)
// MessageReceived is called for each message the read loop parses, with
// its length in bytes.
MessageReceived(bytes int)
}
Metrics records connection activity for one session. Its methods are called from the read and write loops for every message, so they should be cheap and must be safe to call from different goroutines.
type MetricsFactory ¶
MetricsFactory creates the Metrics for each session. It is called once per session, including dynamic sessions, when the session is created.
type NewListenerCallback ¶
NewListenerCallback is a function that returns a net.Listener for the given address and tls.Config struct.
type OnCreateHandler ¶ added in v0.4.0
type OnCreateHandler interface {
// OnCreate notification of a session being created.
OnCreate(sessionID SessionID)
}
OnCreateHandler is implemented by an Application that wants to be told when a session is created. It is optional; see Application.
type OnLogonHandler ¶ added in v0.4.0
type OnLogonHandler interface {
// OnLogon notification of a session successfully logging on.
OnLogon(sessionID SessionID)
}
OnLogonHandler is implemented by an Application that wants to be told when a session logs on. It is optional; see Application.
type OnLogoutHandler ¶ added in v0.4.0
type OnLogoutHandler interface {
// OnLogout notification of a session logging off or disconnecting.
OnLogout(sessionID SessionID)
}
OnLogoutHandler is implemented by an Application that wants to be told when a session logs out. It is optional; see Application.
type Option ¶
type Option func(*options)
Option configures an Acceptor, Initiator or MessageRouter.
func WithMetrics ¶
func WithMetrics(f MetricsFactory) Option
WithMetrics sets the MetricsFactory that creates the Metrics each session records connection activity to. Without it nothing is recorded. It has no effect on a MessageRouter.
func WithRegistry ¶
WithRegistry sets the Registry that sessions are registered in and looked up from. Without it the shared DefaultRegistry is used.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a set of sessions keyed by SessionID. Acceptors and Initiators register their sessions in a Registry, which is the shared DefaultRegistry unless WithRegistry is supplied.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry returns the shared Registry used by Acceptors, Initiators and MessageRouters created without WithRegistry, and by the package level functions such as SendToTarget.
func (*Registry) GetExpectedSenderNum ¶
GetExpectedSenderNum retrieves the expected sender sequence number for the session matching the session id.
func (*Registry) GetExpectedTargetNum ¶
GetExpectedTargetNum retrieves the next target sequence number for the session matching the session id.
func (*Registry) GetMessageStore ¶
func (r *Registry) GetMessageStore(sessionID SessionID) (MessageStore, error)
GetMessageStore returns the MessageStore interface for session matching the session id.
func (*Registry) ResetSession ¶
ResetSession resets session's sequence numbers.
func (*Registry) Send ¶
func (r *Registry) Send(m Messagable) (err error)
Send determines the session to send Messagable using header fields BeginString, TargetCompID, SenderCompID.
func (*Registry) SendToTarget ¶
func (r *Registry) SendToTarget(m Messagable, sessionID SessionID) error
SendToTarget sends a message based on the sessionID. Convenient for use in FromApp since it provides a session ID for incoming messages.
func (*Registry) SetNextSenderMsgSeqNum ¶
SetNextSenderMsgSeqNum sets the next outgoing message sequence number for the session matching the session id.
func (*Registry) SetNextTargetMsgSeqNum ¶
SetNextTargetMsgSeqNum set the next expected target message sequence number for the session matching the session id.
func (*Registry) UnregisterSession ¶
UnregisterSession removes a session from the set of known sessions.
type RejectLogon ¶
type RejectLogon struct {
Text string
}
RejectLogon indicates the application is rejecting permission to logon. Implements MessageRejectError.
func (RejectLogon) BusinessRejectRefID ¶
func (RejectLogon) BusinessRejectRefID() string
BusinessRejectRefID implements MessageRejectError.
func (RejectLogon) Error ¶
func (e RejectLogon) Error() string
func (RejectLogon) IsBusinessReject ¶
func (RejectLogon) IsBusinessReject() bool
IsBusinessReject implements MessageRejectError.
func (RejectLogon) RefTagID ¶
func (RejectLogon) RefTagID() *Tag
RefTagID implements MessageRejectError.
func (RejectLogon) RejectReason ¶
func (RejectLogon) RejectReason() int
RejectReason implements MessageRejectError.
type RepeatingGroup ¶
type RepeatingGroup struct {
// contains filtered or unexported fields
}
RepeatingGroup is a FIX Repeating Group type.
func NewRepeatingGroup ¶
func NewRepeatingGroup(tag Tag, template GroupTemplate) *RepeatingGroup
NewRepeatingGroup returns an initilized RepeatingGroup instance.
func (*RepeatingGroup) Add ¶
func (f *RepeatingGroup) Add() *Group
Add appends a new group to the RepeatingGroup and returns the new Group.
func (RepeatingGroup) Clone ¶
func (f RepeatingGroup) Clone() GroupItem
Clone makes a copy of this RepeatingGroup (tag, template).
func (RepeatingGroup) Get ¶
func (f RepeatingGroup) Get(i int) *Group
Get returns the ith group in this RepeatingGroup.
func (RepeatingGroup) Len ¶
func (f RepeatingGroup) Len() int
Len returns the number of Groups in this RepeatingGroup.
func (*RepeatingGroup) Reset ¶
func (f *RepeatingGroup) Reset()
Reset clears all groups from this RepeatingGroup, allowing the instance to be reused for a new message parse without reallocating the template and struct. This avoids the allocation overhead of calling NewRepeatingGroup for each parse.
func (RepeatingGroup) Tag ¶
func (f RepeatingGroup) Tag() Tag
Tag returns the Tag for this repeating Group.
func (RepeatingGroup) Write ¶
func (f RepeatingGroup) Write() []TagValue
Write returns tagValues for all Items in the repeating group ordered by Group sequence and Group template order.
type SessionHandler ¶
type SessionHandler interface {
OnCreateHandler
OnLogonHandler
OnLogoutHandler
}
SessionHandler is implemented by an Application that wants to be told about all session lifecycle events. It is optional; see Application.
type SessionID ¶
type SessionID struct {
BeginString, TargetCompID, TargetSubID, TargetLocationID, SenderCompID, SenderSubID, SenderLocationID, Qualifier string
}
SessionID is a unique identifier of a Session.
type SessionSettings ¶
type SessionSettings struct {
// contains filtered or unexported fields
}
SessionSettings maps session settings to values with typed accessors.
func NewSessionSettings ¶
func NewSessionSettings() *SessionSettings
NewSessionSettings returns a newly initialized SessionSettings instance.
func (SessionSettings) BoolSetting ¶
func (s SessionSettings) BoolSetting(setting string) (bool, error)
BoolSetting returns the requested setting parsed as a boolean. Returns an error if the setting is not set or cannot be parsed as a bool.
func (*SessionSettings) DurationSetting ¶
func (s *SessionSettings) DurationSetting(setting string) (time.Duration, error)
DurationSetting returns the requested setting parsed as a time.Duration. Returns an error if the setting is not set or cannot be parsed as a time.Duration.
func (*SessionSettings) HasSetting ¶
func (s *SessionSettings) HasSetting(setting string) bool
HasSetting returns true if a setting is set, false if not.
func (*SessionSettings) Init ¶
func (s *SessionSettings) Init()
Init initializes or resets SessionSettings.
func (*SessionSettings) IntSetting ¶
func (s *SessionSettings) IntSetting(setting string) (int, error)
IntSetting returns the requested setting parsed as an int. Returns an errror if the setting is not set or cannot be parsed as an int.
func (*SessionSettings) RawSetting ¶
func (s *SessionSettings) RawSetting(setting string) ([]byte, error)
RawSetting is a settings accessor that returns the raw byte slice value of the setting. Returns an error if the setting is missing.
func (*SessionSettings) Set ¶
func (s *SessionSettings) Set(setting string, val string)
Set assigns a string value to a setting on SessionSettings.
func (*SessionSettings) SetRaw ¶
func (s *SessionSettings) SetRaw(setting string, val []byte)
SetRaw assigns a value to a setting on SessionSettings.
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
The Settings type represents a collection of global and session settings.
func ParseSettings ¶
ParseSettings creates and initializes a Settings instance with config parsed from a Reader. Returns error if the config is has parse errors.
func (*Settings) AddSession ¶
func (s *Settings) AddSession(sessionSettings *SessionSettings) (SessionID, error)
AddSession adds Session Settings to Settings instance. Returns an error if session settings with duplicate sessionID has already been added.
func (*Settings) GlobalSettings ¶
func (s *Settings) GlobalSettings() *SessionSettings
GlobalSettings are default setting inherited by all session settings.
func (*Settings) SessionSettings ¶
func (s *Settings) SessionSettings() map[SessionID]*SessionSettings
SessionSettings return all session settings overlaying globalsettings.
type Tag ¶
type Tag int
Tag is a typed int representing a FIX tag.
type TagValue ¶
type TagValue struct {
// contains filtered or unexported fields
}
TagValue is a low-level FIX field abstraction.
type TimestampPrecision ¶
type TimestampPrecision int
TimestampPrecision defines the precision used by FIXUTCTimestamp.
const ( Millis TimestampPrecision = iota Seconds Micros Nanos )
All TimestampPrecisions supported by FIX.
type ToAdminInterceptor ¶ added in v0.4.0
type ToAdminInterceptor interface {
// ToAdmin notification of admin message being sent to target. The message
// may be modified before it is sent, for example to add credentials to a
// Logon.
ToAdmin(message *Message, sessionID SessionID)
}
ToAdminInterceptor is implemented by an Application that wants to see, or modify, admin messages before they are sent. It is optional; see Application.
type ToAppInterceptor ¶ added in v0.4.0
type ToAppInterceptor interface {
// ToApp notification of app message being sent to target. Returning an
// error, such as ErrDoNotSend, stops the message from being sent.
ToApp(message *Message, sessionID SessionID) error
}
ToAppInterceptor is implemented by an Application that wants to see, modify or veto application messages before they are sent. It is optional; see Application.
type Validator ¶
type Validator interface {
Validate(*Message) MessageRejectError
}
Validator validates a FIX message.
func NewValidator ¶
func NewValidator(settings ValidatorSettings, appDataDictionary, transportDataDictionary *datadictionary.DataDictionary) Validator
NewValidator creates a FIX message validator from the given data dictionaries.
Source Files
¶
- acceptor.go
- application.go
- begin_string.go
- connection.go
- dialer.go
- doc.go
- errors.go
- field.go
- field_map.go
- fix_boolean.go
- fix_bytes.go
- fix_decimal.go
- fix_float.go
- fix_int.go
- fix_string.go
- fix_udecimal.go
- fix_utc_timestamp.go
- in_session.go
- initiator.go
- latent_state.go
- log.go
- logon_state.go
- logout_state.go
- memory_store.go
- message.go
- message_router.go
- metrics.go
- msg_type.go
- not_session_time.go
- null_log.go
- options.go
- parser.go
- pending_timeout.go
- redact.go
- registry.go
- repeating_group.go
- resend_state.go
- session.go
- session_factory.go
- session_id.go
- session_rejects.go
- session_settings.go
- session_state.go
- settings.go
- store.go
- tag.go
- tag_value.go
- tls.go
- validation.go
Directories
¶
| Path | Synopsis |
|---|---|
|
_test
|
|
|
loadgen
command
Command loadgen drives a gofix acceptor and initiator against each other over loopback TCP at a controlled rate, and reports throughput, latency and allocation per message.
|
Command loadgen drives a gofix acceptor and initiator against each other over loopback TCP at a controlled rate, and reports throughput, latency and allocation per message. |
|
test-server
command
|
|
|
cmd
|
|
|
generate-fix
command
|
|
|
generate-fix/internal
Package internal in the cmd/generate-fix binary entrypoint proviodes the tooling for generating FIX bindings from XML spec files.
|
Package internal in the cmd/generate-fix binary entrypoint proviodes the tooling for generating FIX bindings from XML spec files. |
|
Package config declares settings for configuring QuickFIX/Go.
|
Package config declares settings for configuring QuickFIX/Go. |
|
Package datadictionary provides support for parsing and organizing FIX Data Dictionaries
|
Package datadictionary provides support for parsing and organizing FIX Data Dictionaries |
|
tape
Package tape generates a deterministic corpus ("tape") of representative FIX messages for benchmarking and load testing.
|
Package tape generates a deterministic corpus ("tape") of representative FIX messages for benchmarking and load testing. |
|
log
|
|
|
store
|
|
