diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index afe397103..709a7468d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,13 +30,11 @@ jobs: - name: Install golangci-lint run: | curl -sSLO https://github.com/golangci/golangci-lint/releases/download/v$GOLANGCI_LINT_VERSION/golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz - shasum -a 256 golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz | grep "^$GOLANGCI_LINT_SHA256 " > /dev/null tar -xf golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz sudo mv golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64/golangci-lint /usr/local/bin/golangci-lint rm -rf golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64* env: - GOLANGCI_LINT_VERSION: '1.46.2' - GOLANGCI_LINT_SHA256: '242cd4f2d6ac0556e315192e8555784d13da5d1874e51304711570769c4f2b9b' + GOLANGCI_LINT_VERSION: '1.50.1' - name: Run Lint run: make lint diff --git a/Makefile b/Makefile index 5caa90a69..2e0799d43 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test: linters-install: @golangci-lint --version >/dev/null 2>&1 || { \ echo "installing linting tools..."; \ - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.46.2; \ + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.50.1; \ } lint: linters-install diff --git a/acceptor.go b/acceptor.go index 6482331d7..3d72ba20e 100644 --- a/acceptor.go +++ b/acceptor.go @@ -15,7 +15,7 @@ import ( "github.com/quickfixgo/quickfix/config" ) -//Acceptor accepts connections from FIX clients and manages the associated sessions. +// Acceptor accepts connections from FIX clients and manages the associated sessions. type Acceptor struct { app Application settings *Settings @@ -43,7 +43,7 @@ type ConnectionValidator interface { Validate(netConn net.Conn, session SessionID) error } -//Start accepting connections. +// Start accepting connections. func (a *Acceptor) Start() (err error) { socketAcceptHost := "" if a.settings.GlobalSettings().HasSetting(config.SocketAcceptHost) { @@ -112,7 +112,7 @@ func (a *Acceptor) Start() (err error) { return } -//Stop logs out existing sessions, close their connections, and stop accepting new connections. +// Stop logs out existing sessions, close their connections, and stop accepting new connections. func (a *Acceptor) Stop() { defer func() { _ = recover() // suppress sending on closed channel error @@ -141,7 +141,7 @@ func (a *Acceptor) RemoteAddr(sessionID SessionID) (net.Addr, bool) { return val, ok } -//NewAcceptor creates and initializes a new Acceptor. +// NewAcceptor creates and initializes a new Acceptor. func NewAcceptor(app Application, storeFactory MessageStoreFactory, settings *Settings, logFactory LogFactory) (a *Acceptor, err error) { a = &Acceptor{ app: app, @@ -394,7 +394,8 @@ LOOP: // 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) +// +// a.SetConnectionValidator(nil) func (a *Acceptor) SetConnectionValidator(validator ConnectionValidator) { a.connectionValidator = validator } diff --git a/application.go b/application.go index e91ab1021..e7d76c60e 100644 --- a/application.go +++ b/application.go @@ -1,7 +1,7 @@ package quickfix -//Application interface should be implemented by FIX Applications. -//This is the primary interface for processing messages from a FIX Session. +// Application interface should be implemented by FIX Applications. +// This is the primary interface for processing messages from a FIX Session. type Application interface { //OnCreate notification of a session begin created. OnCreate(sessionID SessionID) diff --git a/begin_string.go b/begin_string.go index 74c2a3df5..b5d9f6f14 100644 --- a/begin_string.go +++ b/begin_string.go @@ -1,6 +1,6 @@ package quickfix -//FIX BeginString string values +// FIX BeginString string values const ( BeginStringFIX40 = "FIX.4.0" BeginStringFIX41 = "FIX.4.1" diff --git a/config/configuration.go b/config/configuration.go index d7280e4a3..2af864fd9 100644 --- a/config/configuration.go +++ b/config/configuration.go @@ -2,7 +2,7 @@ package config //NOTE: Additions to this file should be made to both config/doc.go and http://www.quickfixgo.org/docs/ -//Const configuration settings +// Const configuration settings const ( BeginString string = "BeginString" SenderCompID string = "SenderCompID" diff --git a/config/doc.go b/config/doc.go index 197844225..7da502416 100644 --- a/config/doc.go +++ b/config/doc.go @@ -1,264 +1,274 @@ /* Package config declares application and session settings for QuickFIX/Go -BeginString +# BeginString Version of FIX this session should use. Valid values: - FIXT.1.1 - FIX.4.4 - FIX.4.3 - FIX.4.2 - FIX.4.1 - FIX.4.0 + FIXT.1.1 + FIX.4.4 + FIX.4.3 + FIX.4.2 + FIX.4.1 + FIX.4.0 -SenderCompID +# SenderCompID Your ID as associated with this FIX session. Value is case-sensitive alpha-numeric string. -SenderSubID +# SenderSubID (Optional) Your subID as associated with this FIX session. Value is case-sensitive alpha-numeric string. -SenderLocationID +# SenderLocationID (Optional) Your locationID as associated with this FIX session. Value is case-sensitive alpha-numeric string. -TargetCompID +# TargetCompID Counter parties ID as associated with this FIX session. Value is case-sensitive alpha-numeric string. -TargetSubID +# TargetSubID (Optional) Counterparty's subID as associated with this FIX session. Value is case-sensitive alpha-numeric string. -TargetLocationID +# TargetLocationID (Optional) Counterparty's locationID as associated with this FIX session. Value is case-sensitive alpha-numeric string. -SessionQualifier +# SessionQualifier Additional qualifier to disambiguate otherwise identical sessions. Value is case-sensitive alpha-numeric string. -DefaultApplVerID +# DefaultApplVerID Required only for FIXT 1.1 (and newer). Ignored for earlier transport versions. Specifies the default application version ID for the session. This can either be the ApplVerID enum (see the ApplVerID field) or the BeginString for the default version. Valid Values: - FIX.5.0SP2 - FIX.5.0SP1 - FIX.5.0 - FIX.4.4 - FIX.4.3 - FIX.4.2 - FIX.4.1 - FIX.4.0 - 9 - 8 - 7 - 6 - 5 - 4 - 3 - 2 - -TimeZone + FIX.5.0SP2 + FIX.5.0SP1 + FIX.5.0 + FIX.4.4 + FIX.4.3 + FIX.4.2 + FIX.4.1 + FIX.4.0 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + +# TimeZone Time zone for this session; if specified, the session start and end will be converted from this zone to UTC. Valid Values: - IANA Time zone ID (America/New_York, Asia/Tokyo, Europe/London, etc.) - Local (The Zone on host) + IANA Time zone ID (America/New_York, Asia/Tokyo, Europe/London, etc.) + Local (The Zone on host) Defaults to UTC. -StartTime +# StartTime Time of day that this FIX session becomes activated. Valid Values: - time in the format of HH:MM:SS, time is represented in time zone configured by TimeZone + time in the format of HH:MM:SS, time is represented in time zone configured by TimeZone -EndTime +# EndTime Time of day that this FIX session becomes deactivated. Valid Values: - time in the format of HH:MM:SS, time is represented in time zone configured by TimeZone + time in the format of HH:MM:SS, time is represented in time zone configured by TimeZone -StartDay +# StartDay For week long sessions, the starting day of week for the session. Use in combination with StartTime. Valid Values: - Full day of week in English, or 3 letter abbreviation (i.e. Monday and Mon are valid) + Full day of week in English, or 3 letter abbreviation (i.e. Monday and Mon are valid) -EndDay +# EndDay For week long sessions, the ending day of week for the session. Use in combination with EndTime. Valid Values: - Full day of week in English, or 3 letter abbreviation (i.e. Monday and Mon are valid) + Full day of week in English, or 3 letter abbreviation (i.e. Monday and Mon are valid) -EnableLastMsgSeqNumProcessed +# EnableLastMsgSeqNumProcessed Add the last message sequence number processed in the header (optional tag 369). Valid Values: - Y - N + + Y + N Defaults to N. -ResendRequestChunkSize +# ResendRequestChunkSize Setting to limit the size of a resend request in case of missing messages. This is useful when the remote FIX engine does not allow to ask for more than n message for a ResendRequest. E.g. if the ResendRequestChunkSize is set to 5 and a gap of 7 messages is detected, a first resend request will be sent for 5 messages. When this gap has been filled, another resend request for 2 messages will be sent. If the ResendRequestChunkSize is set to 0, only one ResendRequest for all the missing messages will be sent. Value must be positive integer. Defaults to 0 (disables splitting). -ResetOnLogon +# ResetOnLogon Determines if sequence numbers should be reset when receiving a logon request. Acceptors only. Valid Values: - Y - N + + Y + N Defaults to N. -ResetOnLogout +# ResetOnLogout Determines if sequence numbers should be reset to 1 after a normal logout termination. Valid Values: - Y - N + + Y + N Defaults to N. -ResetOnDisconnect +# ResetOnDisconnect Determines if sequence numbers should be reset to 1 after an abnormal termination. Valid Values: - Y - N + + Y + N Defaults to N. -RefreshOnLogon +# RefreshOnLogon Determines if session state should be restored from persistence layer when logging on. Useful for creating hot failover sessions. Valid Values: - Y - N + + Y + N Defaults to N. -TimeStampPrecision +# TimeStampPrecision Determines precision for timestamps in (Orig)SendingTime fields that are sent out. Only available for FIX.4.2 and greater, FIX versions earlier than FIX.4.2 will use timestamp resolution in seconds. Valid Values: - SECONDS - MILLIS - MICROS - NANOS + + SECONDS + MILLIS + MICROS + NANOS Defaults to MILLIS. -Validation +# Validation The following settings are specific to message validation. -DataDictionary +# DataDictionary XML definition file for validating incoming FIX messages. If no DataDictionary is supplied, only basic message validation will be done. This setting should only be used with FIX transport versions older than FIXT.1.1. See TransportDataDictionary and AppDataDictionary for FIXT.1.1 settings. Value must be a valid XML data dictionary file. QuickFIX/Go comes with the following defaults in the spec directory - FIX44.xml - FIX43.xml - FIX42.xml - FIX41.xml - FIX40.xml + FIX44.xml + FIX43.xml + FIX42.xml + FIX41.xml + FIX40.xml -TransportDataDictionary +# TransportDataDictionary XML definition file for validating admin (transport) messages. This setting is only valid for FIXT.1.1 (or newer) sessions. See DataDictionary for older transport versions (FIX.4.0 - FIX.4.4) for additional information. Value must be a valid XML data dictionary file, QuickFIX/Go comes with the following defaults in the spec directory - FIXT1.1.xml + FIXT1.1.xml -AppDataDictionary +# AppDataDictionary XML definition file for validating application messages. This setting is only valid for FIXT.1.1 (or newer) sessions. See DataDictionary for older transport versions (FIX.4.0 - FIX.4.4) for additional information. This setting supports the possibility of a custom application data dictionary for each session. This setting would only be used with FIXT 1.1 and new transport protocols. This setting can be used as a prefix to specify multiple application dictionaries for the FIXT transport. For example: - DefaultApplVerID=FIX.4.2 - # For default application version ID - AppDataDictionary=FIX42.xml - # For nondefault application version ID - # Use BeginString suffix for app version - AppDataDictionary.FIX.4.4=FIX44.xml + DefaultApplVerID=FIX.4.2 + # For default application version ID + AppDataDictionary=FIX42.xml + # For nondefault application version ID + # Use BeginString suffix for app version + AppDataDictionary.FIX.4.4=FIX44.xml Value must be a valid XML data dictionary file. QuickFIX/Go comes with the following defaults in the spec directory - FIX50SP2.xml - FIX50SP1.xml - FIX50.xml - FIX44.xml - FIX43.xml - FIX42.xml - FIX41.xml - FIX40.xml + FIX50SP2.xml + FIX50SP1.xml + FIX50.xml + FIX44.xml + FIX43.xml + FIX42.xml + FIX41.xml + FIX40.xml -ValidateFieldsOutOfOrder +# ValidateFieldsOutOfOrder If set to N, fields that are out of order (i.e. body fields in the header, or header fields in the body) will not be rejected. Useful for connecting to systems which do not properly order fields. Valid Values: - Y - N + + Y + N Defaults to Y. -RejectInvalidMessage +# RejectInvalidMessage If RejectInvalidMessage is set to N, zero errors will be thrown on reception of message that fails data dictionary validation. Valid Values: - Y - N + + Y + N Defaults to Y. -CheckLatency +# CheckLatency If set to Y, messages must be received from the counterparty within a defined number of seconds. It is useful to turn this off if a system uses localtime for it's timestamps instead of GMT. Valid Values: - Y - N + + Y + N Defaults to Y. -MaxLatency +# MaxLatency If CheckLatency is set to Y, this defines the number of seconds latency allowed for a message to be processed. Value must be positive integer. Defaults to 120. -ReconnectInterval +# ReconnectInterval Time between reconnection attempts in seconds. Only used for initiators. Value must be positive integer. -Defaults to 30 +# Defaults to 30 -LogoutTimeout +# LogoutTimeout Session setting for logout timeout in seconds. Only used for initiators. Value must be positive integer. -Defaults to 2 +# Defaults to 2 -LogonTimeout +# LogonTimeout Session setting for logon timeout in seconds. Only used for initiators. Value must be positive integer. -Defaults to 10 +# Defaults to 10 -HeartBtInt +# HeartBtInt Heartbeat interval in seconds. Only used for initiators (unless HeartBtIntOverride is Y). Value must be positive integer. -HeartBtIntOverride +# HeartBtIntOverride If set to Y, will use the HeartBtInt interval rather than what the initiator dictates. Only used for acceptors. Valid Values: - Y - N + + Y + N Defaults to N. -SocketConnectPort +# SocketConnectPort Socket port for connecting to a session. Only used for initiators. Must be positive integer -SocketConnectHost +# SocketConnectHost Host to connect to. Only used for initiators. Value must be a valid IPv4 or IPv6 address or a domain name @@ -270,119 +280,124 @@ SocketConnectHost Alternate socket hosts for connecting to a session for failover, where n is a positive integer. (i.e.) SocketConnectHost1, SocketConnectHost2... must be consecutive and have a matching SocketConnectPort[n]. Value must be a valid IPv4 or IPv6 address or a domain name -SocketTimeout +# SocketTimeout Duration of timeout for TLS handshake. Only used for initiators. Example Values: - SocketTimeout=30s # 30 seconds - SocketTimeout=60m # 60 minutes + + SocketTimeout=30s # 30 seconds + SocketTimeout=60m # 60 minutes Defaults to 0(means nothing timeout). -SocketAcceptHost +# SocketAcceptHost Socket host address for listening on incoming connections, only used for acceptors. By default acceptors listen on all available interfaces. -SocketAcceptPort +# SocketAcceptPort Socket port for listening to incoming connections, only used for acceptors. Value must be a positive integer, valid open socket port. -SocketPrivateKeyFile +# SocketPrivateKeyFile Private key to use for secure TLS connections. Must be used with SocketCertificateFile. -SocketCertificateFile +# SocketCertificateFile Certificate to use for secure TLS connections. Must be used with SocketPrivateKeyFile. -SocketCAFile +# SocketCAFile Optional root CA to use for secure TLS connections. For acceptors, client certificates will be verified against this CA. For initiators, clients will use the CA to verify the server certificate. If not configurated, initiators will verify the server certificate using the host's root CA set. -SocketServerName +# SocketServerName The expected server name on a returned certificate, unless SocketInsecureSkipVerify is true. This is for the TLS Server Name Indication extension. Initiator only. -SocketMinimumTLSVersion +# SocketMinimumTLSVersion Specify the Minimum TLS version to use when creating a secure connection. The valid choices are SSL30, TLS10, TLS11, TLS12. Defaults to TLS12. -SocketUseSSL +# SocketUseSSL Use SSL for initiators even if client certificates are not present. If set to N or omitted, TLS will not be used if SocketPrivateKeyFile or SocketCertificateFile are not supplied. -ProxyType +# ProxyType Proxy type. Valid Values: - socks -ProxyHost + socks + +# ProxyHost -Proxy server IP address in the format of x.x.x.x or a domain name +# Proxy server IP address in the format of x.x.x.x or a domain name -ProxyPort +# ProxyPort -Proxy server port +# Proxy server port -ProxyUser +# ProxyUser -Proxy user +# Proxy user -ProxyPassword +# ProxyPassword -Proxy password +# Proxy password -UseTCPProxy +# UseTCPProxy Use TCP proxy for servers listening behind HAProxy of Amazon ELB load balancers. The server can then receive the address of the client instead of the load balancer's. Valid Values: - Y - N -PersistMessages + Y + N + +# PersistMessages If set to N, no messages will be persisted. This will force QuickFIX/Go to always send GapFills instead of resending messages. Use this if you know you never want to resend a message. Useful for market data streams. Valid Values: - Y - N + + Y + N Defaults to Y. -FileLogPath +# FileLogPath Directory to store logs. Value must be valid directory for storing files, application must have write access. -FileStorePath +# FileStorePath Directory to store sequence number and message files. Only used with FileStoreFactory. -MongoStoreConnection +# MongoStoreConnection The MongoDB connection URL to use (see https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Connect for more info). Only used with MongoStoreFactory. -MongoStoreDatabase +# MongoStoreDatabase The MongoDB-specific name of the database to use. Only used with MongoStoreFactory. -MongoStoreReplicaSet +# MongoStoreReplicaSet The MongoDB-specific name of the replica set to use. Optional, only used with MongoStoreFactory. -SQLStoreDriver +# SQLStoreDriver The name of the database driver to use (see https://github.com/golang/go/wiki/SQLDrivers for the list of available drivers). Only used with SqlStoreFactory. -SQLStoreDataSourceName +# SQLStoreDataSourceName The driver-specific data source name of the database to use. Only used with SqlStoreFactory. -SQLStoreConnMaxLifetime +# SQLStoreConnMaxLifetime SetConnMaxLifetime sets the maximum duration of time that a database connection may be reused (see https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime). Defaults to zero, which causes connections to be reused forever. Only used with SqlStoreFactory. If your database server has a config option to close inactive connections after some duration (e.g. MySQL "wait_timeout"), set SQLConnMaxLifetime to a value less than that duration. Example Values: - SQLConnMaxLifetime=14400s # 14400 seconds - SQLConnMaxLifetime=2h45m # 2 hours and 45 minutes + + SQLConnMaxLifetime=14400s # 14400 seconds + SQLConnMaxLifetime=2h45m # 2 hours and 45 minutes */ package config diff --git a/datadictionary/datadictionary.go b/datadictionary/datadictionary.go index ea93f6b25..b1dc8ef3f 100644 --- a/datadictionary/datadictionary.go +++ b/datadictionary/datadictionary.go @@ -1,4 +1,4 @@ -//Package datadictionary provides support for parsing and organizing FIX Data Dictionaries +// Package datadictionary provides support for parsing and organizing FIX Data Dictionaries package datadictionary import ( @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" ) -//DataDictionary models FIX messages, components, and fields. +// DataDictionary models FIX messages, components, and fields. type DataDictionary struct { FIXType string Major int @@ -23,20 +23,20 @@ type DataDictionary struct { Trailer *MessageDef } -//MessagePart can represent a Field, Repeating Group, or Component +// MessagePart can represent a Field, Repeating Group, or Component type MessagePart interface { Name() string Required() bool } -//messagePartWithFields is a MessagePart with multiple Fields +// messagePartWithFields is a MessagePart with multiple Fields type messagePartWithFields interface { MessagePart Fields() []*FieldDef RequiredFields() []*FieldDef } -//ComponentType is a grouping of fields. +// ComponentType is a grouping of fields. type ComponentType struct { name string parts []MessagePart @@ -45,7 +45,7 @@ type ComponentType struct { requiredParts []MessagePart } -//NewComponentType returns an initialized component type +// NewComponentType returns an initialized component type func NewComponentType(name string, parts []MessagePart) *ComponentType { comp := ComponentType{ name: name, @@ -77,37 +77,37 @@ func NewComponentType(name string, parts []MessagePart) *ComponentType { return &comp } -//Name returns the name of this component type +// Name returns the name of this component type func (c ComponentType) Name() string { return c.name } -//Fields returns all fields contained in this component. Includes fields -//encapsulated in components of this component +// Fields returns all fields contained in this component. Includes fields +// encapsulated in components of this component func (c ComponentType) Fields() []*FieldDef { return c.fields } -//RequiredFields returns those fields that are required for this component +// RequiredFields returns those fields that are required for this component func (c ComponentType) RequiredFields() []*FieldDef { return c.requiredFields } -//RequiredParts returns those parts that are required for this component +// RequiredParts returns those parts that are required for this component func (c ComponentType) RequiredParts() []MessagePart { return c.requiredParts } // Parts returns all parts in declaration order contained in this component func (c ComponentType) Parts() []MessagePart { return c.parts } -//TagSet is set for tags. +// TagSet is set for tags. type TagSet map[int]struct{} -//Add adds a tag to the tagset. +// Add adds a tag to the tagset. func (t TagSet) Add(tag int) { t[tag] = struct{}{} } -//Component is a Component as it appears in a given MessageDef +// Component is a Component as it appears in a given MessageDef type Component struct { *ComponentType required bool } -//NewComponent returns an initialized Component instance +// NewComponent returns an initialized Component instance func NewComponent(ct *ComponentType, required bool) *Component { return &Component{ ComponentType: ct, @@ -115,16 +115,16 @@ func NewComponent(ct *ComponentType, required bool) *Component { } } -//Required returns true if this component is required for the containing -//MessageDef +// Required returns true if this component is required for the containing +// MessageDef func (c Component) Required() bool { return c.required } -//Field models a field or repeating group in a message +// Field models a field or repeating group in a message type Field interface { Tag() int } -//FieldDef models a field belonging to a message. +// FieldDef models a field belonging to a message. type FieldDef struct { *FieldType required bool @@ -135,7 +135,7 @@ type FieldDef struct { requiredFields []*FieldDef } -//NewFieldDef returns an initialized FieldDef +// NewFieldDef returns an initialized FieldDef func NewFieldDef(fieldType *FieldType, required bool) *FieldDef { return &FieldDef{ FieldType: fieldType, @@ -143,7 +143,7 @@ func NewFieldDef(fieldType *FieldType, required bool) *FieldDef { } } -//NewGroupFieldDef returns an initialized FieldDef for a repeating group +// NewGroupFieldDef returns an initialized FieldDef for a repeating group func NewGroupFieldDef(fieldType *FieldType, required bool, parts []MessagePart) *FieldDef { field := FieldDef{ FieldType: fieldType, @@ -178,21 +178,21 @@ func NewGroupFieldDef(fieldType *FieldType, required bool, parts []MessagePart) return &field } -//Required returns true if this FieldDef is required for the containing -//MessageDef +// Required returns true if this FieldDef is required for the containing +// MessageDef func (f FieldDef) Required() bool { return f.required } -//IsGroup is true if the field is a repeating group. +// IsGroup is true if the field is a repeating group. func (f FieldDef) IsGroup() bool { return len(f.Fields) > 0 } -//RequiredParts returns those parts that are required for this FieldDef. IsGroup -//must return true +// RequiredParts returns those parts that are required for this FieldDef. IsGroup +// must return true func (f FieldDef) RequiredParts() []MessagePart { return f.requiredParts } -//RequiredFields returns those fields that are required for this FieldDef. IsGroup -//must return true +// RequiredFields returns those fields that are required for this FieldDef. IsGroup +// must return true func (f FieldDef) RequiredFields() []*FieldDef { return f.requiredFields } func (f FieldDef) childTags() []int { @@ -206,7 +206,7 @@ func (f FieldDef) childTags() []int { return tags } -//FieldType holds information relating to a field. Includes Tag, type, and enums, if defined. +// FieldType holds information relating to a field. Includes Tag, type, and enums, if defined. type FieldType struct { name string tag int @@ -214,7 +214,7 @@ type FieldType struct { Enums map[string]Enum } -//NewFieldType returns a pointer to an initialized FieldType +// NewFieldType returns a pointer to an initialized FieldType func NewFieldType(name string, tag int, fixType string) *FieldType { return &FieldType{ name: name, @@ -223,19 +223,19 @@ func NewFieldType(name string, tag int, fixType string) *FieldType { } } -//Name returns the name for this FieldType +// Name returns the name for this FieldType func (f FieldType) Name() string { return f.name } -//Tag returns the tag for this fieldType +// Tag returns the tag for this fieldType func (f FieldType) Tag() int { return f.tag } -//Enum is a container for value and description. +// Enum is a container for value and description. type Enum struct { Value string Description string } -//MessageDef can apply to header, trailer, or body of a FIX Message. +// MessageDef can apply to header, trailer, or body of a FIX Message. type MessageDef struct { Name string MsgType string @@ -249,10 +249,10 @@ type MessageDef struct { Tags TagSet } -//RequiredParts returns those parts that are required for this Message +// RequiredParts returns those parts that are required for this Message func (m MessageDef) RequiredParts() []MessagePart { return m.requiredParts } -//NewMessageDef returns a pointer to an initialized MessageDef +// NewMessageDef returns a pointer to an initialized MessageDef func NewMessageDef(name, msgType string, parts []MessagePart) *MessageDef { msg := MessageDef{ Name: name, @@ -299,7 +299,7 @@ func NewMessageDef(name, msgType string, parts []MessagePart) *MessageDef { return &msg } -//Parse loads and build a datadictionary instance from an xml file. +// Parse loads and build a datadictionary instance from an xml file. func Parse(path string) (*DataDictionary, error) { var xmlFile *os.File var err error @@ -312,7 +312,7 @@ func Parse(path string) (*DataDictionary, error) { return ParseSrc(xmlFile) } -//ParseSrc loads and build a datadictionary instance from an xml source. +// ParseSrc loads and build a datadictionary instance from an xml source. func ParseSrc(xmlSrc io.Reader) (*DataDictionary, error) { doc := new(XMLDoc) decoder := xml.NewDecoder(xmlSrc) diff --git a/datadictionary/xml.go b/datadictionary/xml.go index 7471a75bc..759a082f4 100644 --- a/datadictionary/xml.go +++ b/datadictionary/xml.go @@ -4,7 +4,7 @@ import ( "encoding/xml" ) -//XMLDoc is the unmarshalled root of a FIX Dictionary. +// XMLDoc is the unmarshalled root of a FIX Dictionary. type XMLDoc struct { Type string `xml:"type,attr"` Major string `xml:"major,attr"` @@ -27,7 +27,7 @@ type XMLComponent struct { Members []*XMLComponentMember `xml:",any"` } -//XMLField represents the fields/field xml element. +// XMLField represents the fields/field xml element. type XMLField struct { Number int `xml:"number,attr"` Name string `xml:"name,attr"` @@ -35,13 +35,13 @@ type XMLField struct { Values []*XMLValue `xml:"value"` } -//XMLValue represents the fields/field/value xml element. +// XMLValue represents the fields/field/value xml element. type XMLValue struct { Enum string `xml:"enum,attr"` Description string `xml:"description,attr"` } -//XMLComponentMember represents child elements of header, trailer, messages/message, and components/component elements +// XMLComponentMember represents child elements of header, trailer, messages/message, and components/component elements type XMLComponentMember struct { XMLName xml.Name Name string `xml:"name,attr"` diff --git a/errors.go b/errors.go index 19ca16e50..f69e9c287 100644 --- a/errors.go +++ b/errors.go @@ -5,10 +5,10 @@ import ( "fmt" ) -//ErrDoNotSend is a convenience error to indicate a DoNotSend in ToApp +// ErrDoNotSend is a convenience error to indicate a DoNotSend in ToApp var ErrDoNotSend = errors.New("Do Not Send") -//rejectReason enum values. +// rejectReason enum values. const ( rejectReasonInvalidTagNumber = 0 rejectReasonRequiredTagMissing = 1 @@ -27,7 +27,7 @@ const ( rejectReasonIncorrectNumInGroupCountForRepeatingGroup = 16 ) -//MessageRejectError is a type of error that can correlate to a message reject. +// MessageRejectError is a type of error that can correlate to a message reject. type MessageRejectError interface { error @@ -38,23 +38,23 @@ type MessageRejectError interface { IsBusinessReject() bool } -//RejectLogon indicates the application is rejecting permission to logon. Implements MessageRejectError +// RejectLogon indicates the application is rejecting permission to logon. Implements MessageRejectError type RejectLogon struct { Text string } func (e RejectLogon) Error() string { return e.Text } -//RefTagID implements MessageRejectError +// RefTagID implements MessageRejectError func (RejectLogon) RefTagID() *Tag { return nil } -//RejectReason implements MessageRejectError +// RejectReason implements MessageRejectError func (RejectLogon) RejectReason() int { return 0 } -//BusinessRejectRefID implements MessageRejectError +// BusinessRejectRefID implements MessageRejectError func (RejectLogon) BusinessRejectRefID() string { return "" } -//IsBusinessReject implements MessageRejectError +// IsBusinessReject implements MessageRejectError func (RejectLogon) IsBusinessReject() bool { return false } type messageRejectError struct { @@ -71,29 +71,29 @@ func (e messageRejectError) RejectReason() int { return e.rejectReason func (e messageRejectError) BusinessRejectRefID() string { return e.businessRejectRefID } func (e messageRejectError) IsBusinessReject() bool { return e.isBusinessReject } -//NewMessageRejectError returns a MessageRejectError with the given error message, reject reason, and optional reftagid +// NewMessageRejectError returns a MessageRejectError with the given error message, reject reason, and optional reftagid func NewMessageRejectError(err string, rejectReason int, refTagID *Tag) MessageRejectError { return messageRejectError{text: err, rejectReason: rejectReason, refTagID: refTagID} } -//NewBusinessMessageRejectError returns a MessageRejectError with the given error mesage, reject reason, and optional reftagid. -//Reject is treated as a business level reject +// NewBusinessMessageRejectError returns a MessageRejectError with the given error mesage, reject reason, and optional reftagid. +// Reject is treated as a business level reject func NewBusinessMessageRejectError(err string, rejectReason int, refTagID *Tag) MessageRejectError { return messageRejectError{text: err, rejectReason: rejectReason, refTagID: refTagID, isBusinessReject: true} } -//NewBusinessMessageRejectErrorWithRefID returns a MessageRejectError with the given error mesage, reject reason, refID, and optional reftagid. -//Reject is treated as a business level reject +// NewBusinessMessageRejectErrorWithRefID returns a MessageRejectError with the given error mesage, reject reason, refID, and optional reftagid. +// Reject is treated as a business level reject func NewBusinessMessageRejectErrorWithRefID(err string, rejectReason int, businessRejectRefID string, refTagID *Tag) MessageRejectError { return messageRejectError{text: err, rejectReason: rejectReason, refTagID: refTagID, businessRejectRefID: businessRejectRefID, isBusinessReject: true} } -//IncorrectDataFormatForValue returns an error indicating a field that cannot be parsed as the type required. +// IncorrectDataFormatForValue returns an error indicating a field that cannot be parsed as the type required. func IncorrectDataFormatForValue(tag Tag) MessageRejectError { return NewMessageRejectError("Incorrect data format for value", rejectReasonIncorrectDataFormatForValue, &tag) } -//repeatingGroupFieldsOutOfOrder returns an error indicating a problem parsing repeating groups fields +// repeatingGroupFieldsOutOfOrder returns an error indicating a problem parsing repeating groups fields func repeatingGroupFieldsOutOfOrder(tag Tag, reason string) MessageRejectError { if reason != "" { reason = fmt.Sprintf("Repeating group fields out of order (%s)", reason) @@ -103,73 +103,73 @@ func repeatingGroupFieldsOutOfOrder(tag Tag, reason string) MessageRejectError { return NewMessageRejectError(reason, rejectReasonRepeatingGroupFieldsOutOfOrder, &tag) } -//ValueIsIncorrect returns an error indicating a field with value that is not valid. +// ValueIsIncorrect returns an error indicating a field with value that is not valid. func ValueIsIncorrect(tag Tag) MessageRejectError { return NewMessageRejectError("Value is incorrect (out of range) for this tag", rejectReasonValueIsIncorrect, &tag) } -//ConditionallyRequiredFieldMissing indicates that the requested field could not be found in the FIX message. +// ConditionallyRequiredFieldMissing indicates that the requested field could not be found in the FIX message. func ConditionallyRequiredFieldMissing(tag Tag) MessageRejectError { return NewBusinessMessageRejectError(fmt.Sprintf("Conditionally Required Field Missing (%d)", tag), rejectReasonConditionallyRequiredFieldMissing, &tag) } -//valueIsIncorrectNoTag returns an error indicating a field with value that is not valid. -//FIXME: to be compliant with legacy tests, for certain value issues, do not include reftag? (11c_NewSeqNoLess) +// valueIsIncorrectNoTag returns an error indicating a field with value that is not valid. +// FIXME: to be compliant with legacy tests, for certain value issues, do not include reftag? (11c_NewSeqNoLess) func valueIsIncorrectNoTag() MessageRejectError { return NewMessageRejectError("Value is incorrect (out of range) for this tag", rejectReasonValueIsIncorrect, nil) } -//InvalidMessageType returns an error to indicate an invalid message type +// InvalidMessageType returns an error to indicate an invalid message type func InvalidMessageType() MessageRejectError { return NewMessageRejectError("Invalid MsgType", rejectReasonInvalidMsgType, nil) } -//UnsupportedMessageType returns an error to indicate an unhandled message. +// UnsupportedMessageType returns an error to indicate an unhandled message. func UnsupportedMessageType() MessageRejectError { return NewBusinessMessageRejectError("Unsupported Message Type", rejectReasonUnsupportedMessageType, nil) } -//TagNotDefinedForThisMessageType returns an error for an invalid tag appearing in a message. +// TagNotDefinedForThisMessageType returns an error for an invalid tag appearing in a message. func TagNotDefinedForThisMessageType(tag Tag) MessageRejectError { return NewMessageRejectError("Tag not defined for this message type", rejectReasonTagNotDefinedForThisMessageType, &tag) } -//tagAppearsMoreThanOnce return an error for multiple tags in a message not detected as a repeating group. +// tagAppearsMoreThanOnce return an error for multiple tags in a message not detected as a repeating group. func tagAppearsMoreThanOnce(tag Tag) MessageRejectError { return NewMessageRejectError("Tag appears more than once", rejectReasonTagAppearsMoreThanOnce, &tag) } -//RequiredTagMissing returns a validation error when a required field cannot be found in a message. +// RequiredTagMissing returns a validation error when a required field cannot be found in a message. func RequiredTagMissing(tag Tag) MessageRejectError { return NewMessageRejectError("Required tag missing", rejectReasonRequiredTagMissing, &tag) } -//incorrectNumInGroupCountForRepeatingGroup returns a validation error when the num in group value for a group does not match actual group size. +// incorrectNumInGroupCountForRepeatingGroup returns a validation error when the num in group value for a group does not match actual group size. func incorrectNumInGroupCountForRepeatingGroup(tag Tag) MessageRejectError { return NewMessageRejectError("Incorrect NumInGroup count for repeating group", rejectReasonIncorrectNumInGroupCountForRepeatingGroup, &tag) } -//tagSpecifiedOutOfRequiredOrder returns validation error when the group order does not match the spec. +// tagSpecifiedOutOfRequiredOrder returns validation error when the group order does not match the spec. func tagSpecifiedOutOfRequiredOrder(tag Tag) MessageRejectError { return NewMessageRejectError("Tag specified out of required order", rejectReasonTagSpecifiedOutOfRequiredOrder, &tag) } -//TagSpecifiedWithoutAValue returns a validation error for when a field has no value. +// TagSpecifiedWithoutAValue returns a validation error for when a field has no value. func TagSpecifiedWithoutAValue(tag Tag) MessageRejectError { return NewMessageRejectError("Tag specified without a value", rejectReasonTagSpecifiedWithoutAValue, &tag) } -//InvalidTagNumber returns a validation error for messages with invalid tags. +// InvalidTagNumber returns a validation error for messages with invalid tags. func InvalidTagNumber(tag Tag) MessageRejectError { return NewMessageRejectError("Invalid tag number", rejectReasonInvalidTagNumber, &tag) } -//compIDProblem creates a reject for msg where msg has invalid comp id values. +// compIDProblem creates a reject for msg where msg has invalid comp id values. func compIDProblem() MessageRejectError { return NewMessageRejectError("CompID problem", rejectReasonCompIDProblem, nil) } -//sendingTimeAccuracyProblem creates a reject for a msg with stale or invalid sending time. +// sendingTimeAccuracyProblem creates a reject for a msg with stale or invalid sending time. func sendingTimeAccuracyProblem() MessageRejectError { return NewMessageRejectError("SendingTime accuracy problem", rejectReasonSendingTimeAccuracyProblem, nil) } diff --git a/field.go b/field.go index 43b9e4d86..81a277cad 100644 --- a/field.go +++ b/field.go @@ -1,49 +1,49 @@ package quickfix -//FieldValueWriter is an interface for writing field values +// FieldValueWriter is an interface for writing field values type FieldValueWriter interface { //Write writes out the contents of the FieldValue to a []byte Write() []byte } -//FieldValueReader is an interface for reading field values +// FieldValueReader is an interface for reading field values 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 } -//The FieldValue interface is used to write/extract typed field values to/from raw bytes +// The FieldValue interface is used to write/extract typed field values to/from raw bytes type FieldValue interface { FieldValueWriter FieldValueReader } -//FieldWriter is an interface for a writing a field +// FieldWriter is an interface for a writing a field type FieldWriter interface { Tag() Tag FieldValueWriter } -//Field is the interface implemented by all typed Fields in a Message +// Field is the interface implemented by all typed Fields in a Message type Field interface { FieldWriter FieldValueReader } -//FieldGroupWriter is an interface for writing a FieldGroup +// FieldGroupWriter is an interface for writing a FieldGroup type FieldGroupWriter interface { Tag() Tag Write() []TagValue } -//FieldGroupReader is an interface for reading a FieldGroup +// FieldGroupReader is an interface for reading a FieldGroup type FieldGroupReader interface { Tag() Tag Read([]TagValue) ([]TagValue, error) } -//FieldGroup is the interface implemented by all typed Groups in a Message +// FieldGroup is the interface implemented by all typed Groups in a Message type FieldGroup interface { Tag() Tag Write() []TagValue diff --git a/field_map.go b/field_map.go index 4bf02e6ab..5d5f94269 100644 --- a/field_map.go +++ b/field_map.go @@ -7,7 +7,7 @@ import ( "time" ) -//field stores a slice of TagValues +// field stores a slice of TagValues type field []TagValue func fieldTag(f field) Tag { @@ -36,7 +36,7 @@ func (t tagSort) Len() int { return len(t.tags) } func (t tagSort) Swap(i, j int) { t.tags[i], t.tags[j] = t.tags[j], t.tags[i] } func (t tagSort) Less(i, j int) bool { return t.compare(t.tags[i], t.tags[j]) } -//FieldMap is a collection of fix fields that make up a fix message. +// FieldMap is a collection of fix fields that make up a fix message. type FieldMap struct { tagLookup map[Tag]field tagSort @@ -56,7 +56,7 @@ func (m *FieldMap) initWithOrdering(ordering tagOrder) { m.compare = ordering } -//Tags returns all of the Field Tags in this FieldMap +// Tags returns all of the Field Tags in this FieldMap func (m FieldMap) Tags() []Tag { m.rwLock.RLock() defer m.rwLock.RUnlock() @@ -69,12 +69,12 @@ func (m FieldMap) Tags() []Tag { return tags } -//Get parses out a field in this FieldMap. Returned reject may indicate the field is not present, or the field value is invalid. +// Get parses out a field in this FieldMap. Returned reject may indicate the field is not present, or the field value is invalid. func (m FieldMap) Get(parser Field) MessageRejectError { return m.GetField(parser.Tag(), parser) } -//Has returns true if the Tag is present in this FieldMap +// Has returns true if the Tag is present in this FieldMap func (m FieldMap) Has(tag Tag) bool { m.rwLock.RLock() defer m.rwLock.RUnlock() @@ -83,7 +83,7 @@ func (m FieldMap) Has(tag Tag) bool { return ok } -//GetField parses of a field with Tag tag. Returned reject may indicate the field is not present, or the field value is invalid. +// GetField parses of a field with Tag tag. Returned reject may indicate the field is not present, or the field value is invalid. func (m FieldMap) GetField(tag Tag, parser FieldValueReader) MessageRejectError { m.rwLock.RLock() defer m.rwLock.RUnlock() @@ -100,7 +100,7 @@ func (m FieldMap) GetField(tag Tag, parser FieldValueReader) MessageRejectError return nil } -//GetBytes is a zero-copy GetField wrapper for []bytes fields +// GetBytes is a zero-copy GetField wrapper for []bytes fields func (m FieldMap) GetBytes(tag Tag) ([]byte, MessageRejectError) { m.rwLock.RLock() defer m.rwLock.RUnlock() @@ -113,7 +113,7 @@ func (m FieldMap) GetBytes(tag Tag) ([]byte, MessageRejectError) { return f[0].value, nil } -//GetBool is a GetField wrapper for bool fields +// GetBool is a GetField wrapper for bool fields func (m FieldMap) GetBool(tag Tag) (bool, MessageRejectError) { var val FIXBoolean if err := m.GetField(tag, &val); err != nil { @@ -122,7 +122,7 @@ func (m FieldMap) GetBool(tag Tag) (bool, MessageRejectError) { return bool(val), nil } -//GetInt is a GetField wrapper for int fields +// GetInt is a GetField wrapper for int fields func (m FieldMap) GetInt(tag Tag) (int, MessageRejectError) { bytes, err := m.GetBytes(tag) if err != nil { @@ -137,7 +137,7 @@ func (m FieldMap) GetInt(tag Tag) (int, MessageRejectError) { return int(val), err } -//GetTime is a GetField wrapper for utc timestamp fields +// GetTime is a GetField wrapper for utc timestamp fields func (m FieldMap) GetTime(tag Tag) (t time.Time, err MessageRejectError) { m.rwLock.RLock() defer m.rwLock.RUnlock() @@ -155,7 +155,7 @@ func (m FieldMap) GetTime(tag Tag) (t time.Time, err MessageRejectError) { return val.Time, err } -//GetString is a GetField wrapper for string fields +// GetString is a GetField wrapper for string fields func (m FieldMap) GetString(tag Tag) (string, MessageRejectError) { var val FIXString if err := m.GetField(tag, &val); err != nil { @@ -164,7 +164,7 @@ func (m FieldMap) GetString(tag Tag) (string, MessageRejectError) { return string(val), nil } -//GetGroup is a Get function specific to Group Fields. +// GetGroup is a Get function specific to Group Fields. func (m FieldMap) GetGroup(parser FieldGroupReader) MessageRejectError { m.rwLock.RLock() defer m.rwLock.RUnlock() @@ -184,35 +184,35 @@ func (m FieldMap) GetGroup(parser FieldGroupReader) MessageRejectError { return nil } -//SetField sets the field with Tag tag +// SetField sets the field with Tag tag func (m *FieldMap) SetField(tag Tag, field FieldValueWriter) *FieldMap { return m.SetBytes(tag, field.Write()) } -//SetBytes sets bytes +// SetBytes sets bytes func (m *FieldMap) SetBytes(tag Tag, value []byte) *FieldMap { f := m.getOrCreate(tag) initField(f, tag, value) return m } -//SetBool is a SetField wrapper for bool fields +// SetBool is a SetField wrapper for bool fields func (m *FieldMap) SetBool(tag Tag, value bool) *FieldMap { return m.SetField(tag, FIXBoolean(value)) } -//SetInt is a SetField wrapper for int fields +// SetInt is a SetField wrapper for int fields func (m *FieldMap) SetInt(tag Tag, value int) *FieldMap { v := FIXInt(value) return m.SetBytes(tag, v.Write()) } -//SetString is a SetField wrapper for string fields +// SetString is a SetField wrapper for string fields func (m *FieldMap) SetString(tag Tag, value string) *FieldMap { return m.SetBytes(tag, []byte(value)) } -//Clear purges all fields from field map +// Clear purges all fields from field map func (m *FieldMap) Clear() { m.rwLock.Lock() defer m.rwLock.Unlock() @@ -223,7 +223,7 @@ func (m *FieldMap) Clear() { } } -//CopyInto overwrites the given FieldMap with this one +// CopyInto overwrites the given FieldMap with this one func (m *FieldMap) CopyInto(to *FieldMap) { m.rwLock.RLock() defer m.rwLock.RUnlock() @@ -266,14 +266,14 @@ func (m *FieldMap) getOrCreate(tag Tag) field { return f } -//Set is a setter for fields +// Set is a setter for fields func (m *FieldMap) Set(field FieldWriter) *FieldMap { f := m.getOrCreate(field.Tag()) initField(f, field.Tag(), field.Write()) return m } -//SetGroup is a setter specific to group fields +// SetGroup is a setter specific to group fields func (m *FieldMap) SetGroup(field FieldGroupWriter) *FieldMap { m.rwLock.Lock() defer m.rwLock.Unlock() diff --git a/file_log.go b/file_log.go index 02f27b001..52146f07e 100644 --- a/file_log.go +++ b/file_log.go @@ -35,8 +35,8 @@ type fileLogFactory struct { sessionLogPaths map[SessionID]string } -//NewFileLogFactory creates an instance of LogFactory that writes messages and events to file. -//The location of global and session log files is configured via FileLogPath. +// NewFileLogFactory creates an instance of LogFactory that writes messages and events to file. +// The location of global and session log files is configured via FileLogPath. func NewFileLogFactory(settings *Settings) (LogFactory, error) { logFactory := fileLogFactory{} diff --git a/fix_boolean.go b/fix_boolean.go index 5cf53b572..2d9bc57fb 100644 --- a/fix_boolean.go +++ b/fix_boolean.go @@ -4,10 +4,10 @@ import ( "errors" ) -//FIXBoolean is a FIX Boolean value, implements FieldValue. +// FIXBoolean is a FIX Boolean value, implements FieldValue. type FIXBoolean bool -//Bool converts the FIXBoolean value to bool +// Bool converts the FIXBoolean value to bool func (f FIXBoolean) Bool() bool { return bool(f) } func (f *FIXBoolean) Read(bytes []byte) error { diff --git a/fix_bytes.go b/fix_bytes.go index 5e3bb1300..8fb14d1a9 100644 --- a/fix_bytes.go +++ b/fix_bytes.go @@ -1,6 +1,6 @@ package quickfix -//FIXBytes is a generic FIX field value, implements FieldValue. Enables zero copy read from a FieldMap +// FIXBytes is a generic FIX field value, implements FieldValue. Enables zero copy read from a FieldMap type FIXBytes []byte func (f *FIXBytes) Read(bytes []byte) (err error) { diff --git a/fix_decimal.go b/fix_decimal.go index d6f8ab1cd..143e69d7a 100644 --- a/fix_decimal.go +++ b/fix_decimal.go @@ -2,7 +2,7 @@ package quickfix import "github.com/shopspring/decimal" -//FIXDecimal is a FIX Float Value that implements an arbitrary precision fixed-point decimal. Implements FieldValue +// FIXDecimal is a FIX Float Value that implements an arbitrary precision fixed-point decimal. Implements FieldValue type FIXDecimal struct { decimal.Decimal diff --git a/fix_float.go b/fix_float.go index 10122936a..28cafa576 100644 --- a/fix_float.go +++ b/fix_float.go @@ -5,10 +5,10 @@ import ( "strconv" ) -//FIXFloat is a FIX Float Value, implements FieldValue +// FIXFloat is a FIX Float Value, implements FieldValue type FIXFloat float64 -//Float64 converts the FIXFloat value to float64 +// Float64 converts the FIXFloat value to float64 func (f FIXFloat) Float64() float64 { return float64(f) } func (f *FIXFloat) Read(bytes []byte) error { diff --git a/fix_int.go b/fix_int.go index b3695116e..645884b95 100644 --- a/fix_int.go +++ b/fix_int.go @@ -14,7 +14,7 @@ const ( ascii9 = 57 ) -//atoi is similar to the function in strconv, but is tuned for ints appearing in FIX field types. +// atoi is similar to the function in strconv, but is tuned for ints appearing in FIX field types. func atoi(d []byte) (int, error) { if d[0] == asciiMinus { n, err := parseUInt(d[1:]) @@ -24,7 +24,7 @@ func atoi(d []byte) (int, error) { return parseUInt(d) } -//parseUInt is similar to the function in strconv, but is tuned for ints appearing in FIX field types. +// parseUInt is similar to the function in strconv, but is tuned for ints appearing in FIX field types. func parseUInt(d []byte) (n int, err error) { if len(d) == 0 { err = errors.New("empty bytes") @@ -43,10 +43,10 @@ func parseUInt(d []byte) (n int, err error) { return } -//FIXInt is a FIX Int Value, implements FieldValue +// FIXInt is a FIX Int Value, implements FieldValue type FIXInt int -//Int converts the FIXInt value to int +// Int converts the FIXInt value to int func (f FIXInt) Int() int { return int(f) } func (f *FIXInt) Read(bytes []byte) error { diff --git a/fix_string.go b/fix_string.go index bfa54ae06..39c2119a1 100644 --- a/fix_string.go +++ b/fix_string.go @@ -1,6 +1,6 @@ package quickfix -//FIXString is a FIX String Value, implements FieldValue +// FIXString is a FIX String Value, implements FieldValue type FIXString string func (f FIXString) String() string { diff --git a/fix_utc_timestamp.go b/fix_utc_timestamp.go index 82c2c2f7d..c6b685ca3 100644 --- a/fix_utc_timestamp.go +++ b/fix_utc_timestamp.go @@ -5,10 +5,10 @@ import ( "time" ) -//TimestampPrecision defines the precision used by FIXUTCTimestamp +// TimestampPrecision defines the precision used by FIXUTCTimestamp type TimestampPrecision int -//All TimestampPrecisions supported by FIX +// All TimestampPrecisions supported by FIX const ( Millis TimestampPrecision = iota Seconds @@ -16,7 +16,7 @@ const ( Nanos ) -//FIXUTCTimestamp is a FIX UTC Timestamp value, implements FieldValue +// FIXUTCTimestamp is a FIX UTC Timestamp value, implements FieldValue type FIXUTCTimestamp struct { time.Time Precision TimestampPrecision diff --git a/initiator.go b/initiator.go index 3b6672395..8426c7f26 100644 --- a/initiator.go +++ b/initiator.go @@ -10,7 +10,7 @@ import ( "golang.org/x/net/proxy" ) -//Initiator initiates connections and processes messages for all sessions. +// Initiator initiates connections and processes messages for all sessions. type Initiator struct { app Application settings *Settings @@ -24,7 +24,7 @@ type Initiator struct { sessionFactory } -//Start Initiator. +// Start Initiator. func (i *Initiator) Start() (err error) { i.stopChan = make(chan interface{}) @@ -50,7 +50,7 @@ func (i *Initiator) Start() (err error) { return } -//Stop Initiator. +// Stop Initiator. func (i *Initiator) Stop() { select { case <-i.stopChan: @@ -62,7 +62,7 @@ func (i *Initiator) Stop() { i.wg.Wait() } -//NewInitiator creates and initializes a new Initiator. +// NewInitiator creates and initializes a new Initiator. func NewInitiator(app Application, storeFactory MessageStoreFactory, appSettings *Settings, logFactory LogFactory) (*Initiator, error) { i := &Initiator{ app: app, @@ -92,7 +92,7 @@ func NewInitiator(app Application, storeFactory MessageStoreFactory, appSettings return i, nil } -//waitForInSessionTime returns true if the session is in session, false if the handler should stop +// waitForInSessionTime returns true if the session is in session, false if the handler should stop func (i *Initiator) waitForInSessionTime(session *session) bool { inSessionTime := make(chan interface{}) go func() { @@ -109,7 +109,7 @@ func (i *Initiator) waitForInSessionTime(session *session) bool { return true } -//waitForReconnectInterval returns true if a reconnect should be re-attempted, false if handler should stop +// waitForReconnectInterval returns true if a reconnect should be re-attempted, false if handler should stop func (i *Initiator) waitForReconnectInterval(reconnectInterval time.Duration) bool { select { case <-time.After(reconnectInterval): diff --git a/internal/event.go b/internal/event.go index 5c6af8db4..7e00cc2b8 100644 --- a/internal/event.go +++ b/internal/event.go @@ -1,6 +1,6 @@ package internal -//Event is an abstraction for session events +// Event is an abstraction for session events type Event int const ( diff --git a/internal/session_settings.go b/internal/session_settings.go index 7547c0fa6..b91d89a0d 100644 --- a/internal/session_settings.go +++ b/internal/session_settings.go @@ -2,7 +2,7 @@ package internal import "time" -//SessionSettings stores all of the configuration for a given session +// SessionSettings stores all of the configuration for a given session type SessionSettings struct { ResetOnLogon bool RefreshOnLogon bool diff --git a/internal/time_range.go b/internal/time_range.go index e69f2fd21..4b7f9d7c7 100644 --- a/internal/time_range.go +++ b/internal/time_range.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" ) -//TimeOfDay represents the time of day +// TimeOfDay represents the time of day type TimeOfDay struct { hour, minute, second int d time.Duration @@ -14,7 +14,7 @@ type TimeOfDay struct { const shortForm = "15:04:05" -//NewTimeOfDay returns a newly initialized TimeOfDay +// NewTimeOfDay returns a newly initialized TimeOfDay func NewTimeOfDay(hour, minute, second int) TimeOfDay { d := time.Duration(second)*time.Second + time.Duration(minute)*time.Minute + @@ -23,7 +23,7 @@ func NewTimeOfDay(hour, minute, second int) TimeOfDay { return TimeOfDay{hour: hour, minute: minute, second: second, d: d} } -//ParseTimeOfDay parses a TimeOfDay from a string in the format HH:MM:SS +// ParseTimeOfDay parses a TimeOfDay from a string in the format HH:MM:SS func ParseTimeOfDay(str string) (TimeOfDay, error) { t, err := time.Parse(shortForm, str) if err != nil { @@ -33,19 +33,19 @@ func ParseTimeOfDay(str string) (TimeOfDay, error) { return NewTimeOfDay(t.Clock()), nil } -//TimeRange represents a time band in a given time zone +// TimeRange represents a time band in a given time zone type TimeRange struct { startTime, endTime TimeOfDay startDay, endDay *time.Weekday loc *time.Location } -//NewUTCTimeRange returns a time range in UTC +// NewUTCTimeRange returns a time range in UTC func NewUTCTimeRange(start, end TimeOfDay) *TimeRange { return NewTimeRangeInLocation(start, end, time.UTC) } -//NewTimeRangeInLocation returns a time range in a given location +// NewTimeRangeInLocation returns a time range in a given location func NewTimeRangeInLocation(start, end TimeOfDay, loc *time.Location) *TimeRange { if loc == nil { panic("time: missing Location in call to NewTimeRangeInLocation") @@ -54,12 +54,12 @@ func NewTimeRangeInLocation(start, end TimeOfDay, loc *time.Location) *TimeRange return &TimeRange{startTime: start, endTime: end, loc: loc} } -//NewUTCWeekRange returns a weekly TimeRange +// NewUTCWeekRange returns a weekly TimeRange func NewUTCWeekRange(startTime, endTime TimeOfDay, startDay, endDay time.Weekday) *TimeRange { return NewWeekRangeInLocation(startTime, endTime, startDay, endDay, time.UTC) } -//NewWeekRangeInLocation returns a time range in a given location +// NewWeekRangeInLocation returns a time range in a given location func NewWeekRangeInLocation(startTime, endTime TimeOfDay, startDay, endDay time.Weekday, loc *time.Location) *TimeRange { r := NewTimeRangeInLocation(startTime, endTime, loc) r.startDay = &startDay @@ -120,7 +120,7 @@ func (r *TimeRange) isInWeekRange(t time.Time) bool { return true } -//IsInRange returns true if time t is within in the time range +// IsInRange returns true if time t is within in the time range func (r *TimeRange) IsInRange(t time.Time) bool { if r == nil { return true @@ -133,7 +133,7 @@ func (r *TimeRange) IsInRange(t time.Time) bool { return r.isInTimeRange(t) } -//IsInSameRange determines if two points in time are in the same time range +// IsInSameRange determines if two points in time are in the same time range func (r *TimeRange) IsInSameRange(t1, t2 time.Time) bool { if r == nil { return true diff --git a/log.go b/log.go index 6b1fa04bb..d346a5d7a 100644 --- a/log.go +++ b/log.go @@ -1,6 +1,6 @@ package quickfix -//Log is a generic interface for logging FIX messages and events. +// Log is a generic interface for logging FIX messages and events. type Log interface { //OnIncoming log incoming fix message OnIncoming([]byte) @@ -15,7 +15,7 @@ type Log interface { OnEventf(string, ...interface{}) } -//The LogFactory interface creates global and session specific Log instances +// The LogFactory interface creates global and session specific Log instances type LogFactory interface { //Create global log Create() (Log, error) diff --git a/message.go b/message.go index d76e5ca44..0a637346b 100644 --- a/message.go +++ b/message.go @@ -9,10 +9,10 @@ import ( "github.com/quickfixgo/quickfix/datadictionary" ) -//Header is first section of a FIX Message +// Header is first section of a FIX Message type Header struct{ FieldMap } -//in the message header, the first 3 tags in the message header must be 8,9,35 +// in the message header, the first 3 tags in the message header must be 8,9,35 func headerFieldOrdering(i, j Tag) bool { var ordering = func(t Tag) uint32 { switch t { @@ -40,20 +40,20 @@ func headerFieldOrdering(i, j Tag) bool { return i < j } -//Init initializes the Header instance +// Init initializes the Header instance func (h *Header) Init() { h.initWithOrdering(headerFieldOrdering) } -//Body is the primary application section of a FIX message +// Body is the primary application section of a FIX message type Body struct{ FieldMap } -//Init initializes the FIX message +// Init initializes the FIX message func (b *Body) Init() { b.init() } -//Trailer is the last section of a FIX message +// Trailer is the last section of a FIX message type Trailer struct{ FieldMap } // In the trailer, CheckSum (tag 10) must be last @@ -68,12 +68,12 @@ func trailerFieldOrdering(i, j Tag) bool { return i < j } -//Init initializes the FIX message +// Init initializes the FIX message func (t *Trailer) Init() { t.initWithOrdering(trailerFieldOrdering) } -//Message is a FIX Message abstraction. +// Message is a FIX Message abstraction. type Message struct { Header Header Trailer Trailer @@ -94,17 +94,17 @@ type Message struct { keepMessage bool } -//ToMessage returns the message itself +// ToMessage returns the message itself func (m *Message) ToMessage() *Message { return m } -//parseError is returned when bytes cannot be parsed as a FIX message. +// parseError is returned when bytes cannot be parsed as a FIX message. type parseError struct { OrigError string } func (e parseError) Error() string { return fmt.Sprintf("error parsing message: %s", e.OrigError) } -//NewMessage returns a newly initialized Message instance +// NewMessage returns a newly initialized Message instance func NewMessage() *Message { m := new(Message) m.Header.Init() @@ -130,12 +130,12 @@ func (m *Message) CopyInto(to *Message) { } } -//ParseMessage constructs a Message from a byte slice wrapping a FIX message. +// ParseMessage constructs a Message from a byte slice wrapping a FIX message. func ParseMessage(msg *Message, rawMessage *bytes.Buffer) (err error) { return ParseMessageWithDataDictionary(msg, rawMessage, nil, nil) } -//ParseMessageWithDataDictionary constructs a Message from a byte slice wrapping a FIX message using an optional session and application DataDictionary for reference. +// ParseMessageWithDataDictionary constructs a Message from a byte slice wrapping a FIX message using an optional session and application DataDictionary for reference. func ParseMessageWithDataDictionary( msg *Message, rawMessage *bytes.Buffer, @@ -287,7 +287,7 @@ func (m *Message) IsMsgTypeOf(msgType string) bool { return false } -//reverseRoute returns a message builder with routing header fields initialized as the reverse of this message. +// reverseRoute returns a message builder with routing header fields initialized as the reverse of this message. func (m *Message) reverseRoute() *Message { reverseMsg := NewMessage() @@ -362,7 +362,7 @@ func formatCheckSum(value int) string { return fmt.Sprintf("%03d", value) } -//Build constructs a []byte from a Message instance +// Build constructs a []byte from a Message instance func (m *Message) build() []byte { m.cook() diff --git a/message_router.go b/message_router.go index 8cc76bf73..03e57f867 100644 --- a/message_router.go +++ b/message_router.go @@ -5,7 +5,7 @@ type routeKey struct { MsgType string } -//FIX ApplVerID string values +// FIX ApplVerID string values const ( ApplVerIDFIX27 = "0" ApplVerIDFIX30 = "1" @@ -19,25 +19,25 @@ const ( ApplVerIDFIX50SP2 = "9" ) -//A MessageRoute is a function that can process a fromApp/fromAdmin callback +// A MessageRoute is a function that can process a fromApp/fromAdmin callback type MessageRoute func(msg *Message, sessionID SessionID) MessageRejectError -//A MessageRouter is a mutex for MessageRoutes +// A MessageRouter is a mutex for MessageRoutes type MessageRouter struct { routes map[routeKey]MessageRoute } -//NewMessageRouter returns an initialized MessageRouter instance +// NewMessageRouter returns an initialized MessageRouter instance func NewMessageRouter() *MessageRouter { return &MessageRouter{routes: make(map[routeKey]MessageRoute)} } -//AddRoute adds a route to the MessageRouter instance keyed to begin string and msgType. +// AddRoute adds a route to the MessageRouter instance keyed to begin string and msgType. func (c MessageRouter) AddRoute(beginString string, msgType string, router MessageRoute) { c.routes[routeKey{beginString, msgType}] = router } -//Route may be called from the fromApp/fromAdmin callbacks. Messages that cannot be routed will be rejected with UnsupportedMessageType. +// Route may be called from the fromApp/fromAdmin callbacks. Messages that cannot be routed will be rejected with UnsupportedMessageType. func (c MessageRouter) Route(msg *Message, sessionID SessionID) MessageRejectError { beginString, err := msg.Header.GetBytes(tagBeginString) if err != nil { diff --git a/msg_type.go b/msg_type.go index 03faed698..309f302f4 100644 --- a/msg_type.go +++ b/msg_type.go @@ -10,7 +10,7 @@ var msgTypeReject = []byte("3") var msgTypeSequenceReset = []byte("4") var msgTypeLogout = []byte("5") -//isAdminMessageType returns true if the message type is a session level message. +// isAdminMessageType returns true if the message type is a session level message. func isAdminMessageType(m []byte) bool { switch { case bytes.Equal(msgTypeHeartbeat, m), diff --git a/null_log.go b/null_log.go index 3d6f02ba1..786271c42 100644 --- a/null_log.go +++ b/null_log.go @@ -16,7 +16,7 @@ func (nullLogFactory) CreateSessionLog(sessionID SessionID) (Log, error) { return nullLog{}, nil } -//NewNullLogFactory creates an instance of LogFactory that returns no-op loggers. +// NewNullLogFactory creates an instance of LogFactory that returns no-op loggers. func NewNullLogFactory() LogFactory { return nullLogFactory{} } diff --git a/quickfix_test.go b/quickfix_test.go index 189aaf21f..575a28614 100644 --- a/quickfix_test.go +++ b/quickfix_test.go @@ -52,7 +52,7 @@ func (s *QuickFIXSuite) MessageEqualsBytes(expectedBytes []byte, msg *Message) { s.Equal(string(actualBytes), string(expectedBytes)) } -//MockStore wraps a memory store and mocks Refresh for convenience +// MockStore wraps a memory store and mocks Refresh for convenience type MockStore struct { mock.Mock memoryStore diff --git a/registry.go b/registry.go index 3c1fb2af8..ffbcd1914 100644 --- a/registry.go +++ b/registry.go @@ -10,12 +10,12 @@ var sessions = make(map[SessionID]*session) var errDuplicateSessionID = errors.New("Duplicate SessionID") var errUnknownSession = errors.New("Unknown session") -//Messagable is a Message or something that can be converted to a Message +// Messagable is a Message or something that can be converted to a Message type Messagable interface { ToMessage() *Message } -//Send determines the session to send Messagable using header fields BeginString, TargetCompID, SenderCompID +// Send determines the session to send Messagable using header fields BeginString, TargetCompID, SenderCompID func Send(m Messagable) (err error) { msg := m.ToMessage() var beginString FIXString @@ -39,7 +39,7 @@ func Send(m Messagable) (err error) { return SendToTarget(msg, sessionID) } -//SendToTarget sends a message based on the sessionID. Convenient for use in FromApp since it provides a session ID for incoming messages +// SendToTarget sends a message based on the sessionID. Convenient for use in FromApp since it provides a session ID for incoming messages func SendToTarget(m Messagable, sessionID SessionID) error { msg := m.ToMessage() session, ok := lookupSession(sessionID) @@ -50,7 +50,7 @@ func SendToTarget(m Messagable, sessionID SessionID) error { return session.queueForSend(msg) } -//UnregisterSession removes a session from the set of known sessions +// UnregisterSession removes a session from the set of known sessions func UnregisterSession(sessionID SessionID) error { sessionsLock.Lock() defer sessionsLock.Unlock() diff --git a/repeating_group.go b/repeating_group.go index 10b4150fc..173cfa116 100644 --- a/repeating_group.go +++ b/repeating_group.go @@ -6,7 +6,7 @@ import ( "strconv" ) -//GroupItem interface is used to construct repeating group templates +// GroupItem interface is used to construct repeating group templates type GroupItem interface { //Tag returns the tag identifying this GroupItem Tag() Tag @@ -38,15 +38,15 @@ func (t protoGroupElement) Read(tv []TagValue) ([]TagValue, error) { func (t protoGroupElement) Clone() GroupItem { return t } -//GroupElement returns a GroupItem made up of a single field +// GroupElement returns a GroupItem made up of a single field func GroupElement(tag Tag) GroupItem { return protoGroupElement{tag: tag} } -//GroupTemplate specifies the group item order for a RepeatingGroup +// GroupTemplate specifies the group item order for a RepeatingGroup type GroupTemplate []GroupItem -//Clone makes a copy of this GroupTemplate +// Clone makes a copy of this GroupTemplate func (gt GroupTemplate) Clone() GroupTemplate { clone := make(GroupTemplate, len(gt)) for i := range gt { @@ -56,17 +56,17 @@ func (gt GroupTemplate) Clone() GroupTemplate { return clone } -//Group is a group of fields occurring in a repeating group +// Group is a group of fields occurring in a repeating group type Group struct{ FieldMap } -//RepeatingGroup is a FIX Repeating Group type +// RepeatingGroup is a FIX Repeating Group type type RepeatingGroup struct { tag Tag template GroupTemplate groups []*Group } -//NewRepeatingGroup returns an initilized RepeatingGroup instance +// NewRepeatingGroup returns an initilized RepeatingGroup instance func NewRepeatingGroup(tag Tag, template GroupTemplate) *RepeatingGroup { return &RepeatingGroup{ tag: tag, @@ -74,12 +74,12 @@ func NewRepeatingGroup(tag Tag, template GroupTemplate) *RepeatingGroup { } } -//Tag returns the Tag for this repeating Group +// Tag returns the Tag for this repeating Group func (f RepeatingGroup) Tag() Tag { return f.tag } -//Clone makes a copy of this RepeatingGroup (tag, template) +// Clone makes a copy of this RepeatingGroup (tag, template) func (f RepeatingGroup) Clone() GroupItem { return &RepeatingGroup{ tag: f.tag, @@ -87,17 +87,17 @@ func (f RepeatingGroup) Clone() GroupItem { } } -//Len returns the number of Groups in this RepeatingGroup +// Len returns the number of Groups in this RepeatingGroup func (f RepeatingGroup) Len() int { return len(f.groups) } -//Get returns the ith group in this RepeatingGroup +// Get returns the ith group in this RepeatingGroup func (f RepeatingGroup) Get(i int) *Group { return f.groups[i] } -//Add appends a new group to the RepeatingGroup and returns the new Group +// Add appends a new group to the RepeatingGroup and returns the new Group func (f *RepeatingGroup) Add() *Group { g := new(Group) g.initWithOrdering(f.groupTagOrder()) @@ -106,8 +106,8 @@ func (f *RepeatingGroup) Add() *Group { return g } -//Write returns tagValues for all Items in the repeating group ordered by -//Group sequence and Group template order +// Write returns tagValues for all Items in the repeating group ordered by +// Group sequence and Group template order func (f RepeatingGroup) Write() []TagValue { tvs := make([]TagValue, 1) tvs[0].init(f.tag, []byte(strconv.Itoa(len(f.groups)))) diff --git a/screen_log.go b/screen_log.go index 0fcd4ebdb..e6271ecc0 100644 --- a/screen_log.go +++ b/screen_log.go @@ -40,7 +40,7 @@ func (screenLogFactory) CreateSessionLog(sessionID SessionID) (Log, error) { return log, nil } -//NewScreenLogFactory creates an instance of LogFactory that writes messages and events to stdout. +// NewScreenLogFactory creates an instance of LogFactory that writes messages and events to stdout. func NewScreenLogFactory() LogFactory { return screenLogFactory{} } diff --git a/session_factory.go b/session_factory.go index 8fc42d3c0..769e5084a 100644 --- a/session_factory.go +++ b/session_factory.go @@ -46,7 +46,7 @@ type sessionFactory struct { BuildInitiators bool } -//Creates Session, associates with internal session registry +// Creates Session, associates with internal session registry func (f sessionFactory) createSession( sessionID SessionID, storeFactory MessageStoreFactory, settings *SessionSettings, logFactory LogFactory, application Application, diff --git a/session_id.go b/session_id.go index 9ee621c52..c3ce615fe 100644 --- a/session_id.go +++ b/session_id.go @@ -7,7 +7,7 @@ type SessionID struct { BeginString, TargetCompID, TargetSubID, TargetLocationID, SenderCompID, SenderSubID, SenderLocationID, Qualifier string } -//IsFIXT returns true if the SessionID has a FIXT BeginString +// IsFIXT returns true if the SessionID has a FIXT BeginString func (s SessionID) IsFIXT() bool { return s.BeginString == BeginStringFIXT11 } diff --git a/session_rejects.go b/session_rejects.go index ba9e6ec23..2edfcd280 100644 --- a/session_rejects.go +++ b/session_rejects.go @@ -4,12 +4,12 @@ import ( "fmt" ) -//IncorrectBeginString is a message reject specific to incorrect begin strings. +// IncorrectBeginString is a message reject specific to incorrect begin strings. type incorrectBeginString struct{ messageRejectError } func (e incorrectBeginString) Error() string { return "Incorrect BeginString" } -//targetTooHigh is a MessageReject where the sequence number is larger than expected. +// targetTooHigh is a MessageReject where the sequence number is larger than expected. type targetTooHigh struct { messageRejectError ReceivedTarget int @@ -20,7 +20,7 @@ func (e targetTooHigh) Error() string { return fmt.Sprintf("MsgSeqNum too high, expecting %d but received %d", e.ExpectedTarget, e.ReceivedTarget) } -//targetTooLow is a MessageReject where the sequence number is less than expected. +// targetTooLow is a MessageReject where the sequence number is less than expected. type targetTooLow struct { messageRejectError ReceivedTarget int diff --git a/session_settings.go b/session_settings.go index 17889eccc..49afbcd7f 100644 --- a/session_settings.go +++ b/session_settings.go @@ -6,12 +6,12 @@ import ( "time" ) -//SessionSettings maps session settings to values with typed accessors. +// SessionSettings maps session settings to values with typed accessors. type SessionSettings struct { settings map[string]string } -//ConditionallyRequiredSetting indicates a missing setting +// ConditionallyRequiredSetting indicates a missing setting type ConditionallyRequiredSetting struct { Setting string } @@ -20,7 +20,7 @@ func (e ConditionallyRequiredSetting) Error() string { return fmt.Sprintf("Conditionally Required Setting: %v", e.Setting) } -//IncorrectFormatForSetting indicates a setting that is incorrectly formatted +// IncorrectFormatForSetting indicates a setting that is incorrectly formatted type IncorrectFormatForSetting struct { Setting, Value string Err error @@ -30,12 +30,12 @@ func (e IncorrectFormatForSetting) Error() string { return fmt.Sprintf("%q is invalid for %s", e.Value, e.Setting) } -//Init initializes or resets SessionSettings +// Init initializes or resets SessionSettings func (s *SessionSettings) Init() { s.settings = make(map[string]string) } -//NewSessionSettings returns a newly initialized SessionSettings instance +// NewSessionSettings returns a newly initialized SessionSettings instance func NewSessionSettings() *SessionSettings { s := &SessionSettings{} s.Init() @@ -43,7 +43,7 @@ func NewSessionSettings() *SessionSettings { return s } -//Set assigns a value to a setting on SessionSettings. +// Set assigns a value to a setting on SessionSettings. func (s *SessionSettings) Set(setting string, val string) { //lazy init if s.settings == nil { @@ -53,13 +53,13 @@ func (s *SessionSettings) Set(setting string, val string) { s.settings[setting] = val } -//HasSetting returns true if a setting is set, false if not +// HasSetting returns true if a setting is set, false if not func (s *SessionSettings) HasSetting(setting string) bool { _, ok := s.settings[setting] return ok } -//Setting is a settings string accessor. Returns an error if the setting is missing. +// Setting is a settings string accessor. Returns an error if the setting is missing. func (s *SessionSettings) Setting(setting string) (string, error) { val, ok := s.settings[setting] if !ok { @@ -69,7 +69,7 @@ func (s *SessionSettings) Setting(setting string) (string, error) { return val, nil } -//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. +// 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 (s *SessionSettings) IntSetting(setting string) (val int, err error) { stringVal, err := s.Setting(setting) @@ -84,8 +84,8 @@ func (s *SessionSettings) IntSetting(setting string) (val int, err error) { return } -//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. +// 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 (s *SessionSettings) DurationSetting(setting string) (val time.Duration, err error) { stringVal, err := s.Setting(setting) @@ -100,7 +100,7 @@ func (s *SessionSettings) DurationSetting(setting string) (val time.Duration, er return } -//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. +// 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 (s SessionSettings) BoolSetting(setting string) (bool, error) { stringVal, err := s.Setting(setting) diff --git a/session_state.go b/session_state.go index 55e341365..016cb3e8c 100644 --- a/session_state.go +++ b/session_state.go @@ -190,8 +190,8 @@ func handleStateError(s *session, err error) sessionState { return latentState{} } -//sessionState is the current state of the session state machine. The session state determines how the session responds to -//incoming messages, timeouts, and requests to send application messages. +// sessionState is the current state of the session state machine. The session state determines how the session responds to +// incoming messages, timeouts, and requests to send application messages. type sessionState interface { //FixMsgIn is called by the session on incoming messages from the counter party. The return type is the next session state //following message processing diff --git a/settings.go b/settings.go index 870cf3d71..f70bf9596 100644 --- a/settings.go +++ b/settings.go @@ -10,13 +10,13 @@ import ( "github.com/quickfixgo/quickfix/config" ) -//The Settings type represents a collection of global and session settings. +// The Settings type represents a collection of global and session settings. type Settings struct { globalSettings *SessionSettings sessionSettings map[SessionID]*SessionSettings } -//Init initializes or resets a Settings instance +// Init initializes or resets a Settings instance func (s *Settings) Init() { s.globalSettings = NewSessionSettings() s.sessionSettings = make(map[SessionID]*SessionSettings) @@ -28,7 +28,7 @@ func (s *Settings) lazyInit() { } } -//NewSettings creates a Settings instance +// NewSettings creates a Settings instance func NewSettings() *Settings { s := &Settings{} s.Init() @@ -75,8 +75,8 @@ func sessionIDFromSessionSettings(globalSettings *SessionSettings, sessionSettin return sessionID } -//ParseSettings creates and initializes a Settings instance with config parsed from a Reader. -//Returns error if the config is has parse errors +// ParseSettings creates and initializes a Settings instance with config parsed from a Reader. +// Returns error if the config is has parse errors func ParseSettings(reader io.Reader) (*Settings, error) { s := NewSettings() @@ -130,13 +130,13 @@ func ParseSettings(reader io.Reader) (*Settings, error) { return s, err } -//GlobalSettings are default setting inherited by all session settings. +// GlobalSettings are default setting inherited by all session settings. func (s *Settings) GlobalSettings() *SessionSettings { s.lazyInit() return s.globalSettings } -//SessionSettings return all session settings overlaying globalsettings. +// SessionSettings return all session settings overlaying globalsettings. func (s *Settings) SessionSettings() map[SessionID]*SessionSettings { allSessionSettings := make(map[SessionID]*SessionSettings) @@ -149,7 +149,7 @@ func (s *Settings) SessionSettings() map[SessionID]*SessionSettings { return allSessionSettings } -//AddSession adds Session Settings to Settings instance. Returns an error if session settings with duplicate sessionID has already been added +// AddSession adds Session Settings to Settings instance. Returns an error if session settings with duplicate sessionID has already been added func (s *Settings) AddSession(sessionSettings *SessionSettings) (SessionID, error) { s.lazyInit() diff --git a/store.go b/store.go index b743a46cc..0ad5123fa 100644 --- a/store.go +++ b/store.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" ) -//The MessageStore interface provides methods to record and retrieve messages for resend purposes +// The MessageStore interface provides methods to record and retrieve messages for resend purposes type MessageStore interface { NextSenderMsgSeqNum() int NextTargetMsgSeqNum() int @@ -29,7 +29,7 @@ type MessageStore interface { Close() error } -//The MessageStoreFactory interface is used by session to create a session specific message store +// The MessageStoreFactory interface is used by session to create a session specific message store type MessageStoreFactory interface { Create(sessionID SessionID) (MessageStore, error) } @@ -126,5 +126,5 @@ func (f memoryStoreFactory) Create(sessionID SessionID) (MessageStore, error) { return m, nil } -//NewMemoryStoreFactory returns a MessageStoreFactory instance that created in-memory MessageStores +// NewMemoryStoreFactory returns a MessageStoreFactory instance that created in-memory MessageStores func NewMemoryStoreFactory() MessageStoreFactory { return memoryStoreFactory{} } diff --git a/tag.go b/tag.go index 20fcda0b7..475c7316a 100644 --- a/tag.go +++ b/tag.go @@ -1,6 +1,6 @@ package quickfix -//Tag is a typed int representing a FIX tag +// Tag is a typed int representing a FIX tag type Tag int const ( @@ -61,7 +61,7 @@ const ( tagCheckSum Tag = 10 ) -//IsTrailer returns true if tag belongs in the message trailer +// IsTrailer returns true if tag belongs in the message trailer func (t Tag) IsTrailer() bool { switch t { case tagSignatureLength, tagSignature, tagCheckSum: @@ -70,7 +70,7 @@ func (t Tag) IsTrailer() bool { return false } -//IsHeader returns true if tag belongs in the message header +// IsHeader returns true if tag belongs in the message header func (t Tag) IsHeader() bool { switch t { case tagBeginString, diff --git a/tag_value.go b/tag_value.go index 762ea233a..75f532a85 100644 --- a/tag_value.go +++ b/tag_value.go @@ -6,7 +6,7 @@ import ( "strconv" ) -//TagValue is a low-level FIX field abstraction +// TagValue is a low-level FIX field abstraction type TagValue struct { tag Tag value []byte diff --git a/tls.go b/tls.go index e8a541c0b..62c7207f3 100644 --- a/tls.go +++ b/tls.go @@ -97,7 +97,7 @@ func loadTLSConfig(settings *SessionSettings) (tlsConfig *tls.Config, err error) return } -//defaultTLSConfig brought to you by https://github.com/gtank/cryptopasta/ +// defaultTLSConfig brought to you by https://github.com/gtank/cryptopasta/ func defaultTLSConfig() *tls.Config { return &tls.Config{ // Avoids most of the memorably-named TLS attacks diff --git a/validation.go b/validation.go index 2a3d61dd6..14f6f9f0d 100644 --- a/validation.go +++ b/validation.go @@ -4,19 +4,19 @@ import ( "github.com/quickfixgo/quickfix/datadictionary" ) -//Validator validates a FIX message +// Validator validates a FIX message type Validator interface { Validate(*Message) MessageRejectError } -//ValidatorSettings describe validation behavior +// ValidatorSettings describe validation behavior type ValidatorSettings struct { CheckFieldsOutOfOrder bool RejectInvalidMessage bool } -//Default configuration for message validation. -//See http://www.quickfixengine.org/quickfix/doc/html/configuration.html. +// Default configuration for message validation. +// See http://www.quickfixengine.org/quickfix/doc/html/configuration.html. var defaultValidatorSettings = ValidatorSettings{ CheckFieldsOutOfOrder: true, RejectInvalidMessage: true, @@ -33,7 +33,7 @@ type fixtValidator struct { settings ValidatorSettings } -//NewValidator creates a FIX message validator from the given data dictionaries +// NewValidator creates a FIX message validator from the given data dictionaries func NewValidator(settings ValidatorSettings, appDataDictionary, transportDataDictionary *datadictionary.DataDictionary) Validator { if transportDataDictionary != nil { return &fixtValidator{ @@ -48,7 +48,7 @@ func NewValidator(settings ValidatorSettings, appDataDictionary, transportDataDi } } -//Validate tests the message against the provided data dictionary. +// Validate tests the message against the provided data dictionary. func (v *fixValidator) Validate(msg *Message) MessageRejectError { if !msg.Header.Has(tagMsgType) { return RequiredTagMissing(tagMsgType) @@ -61,8 +61,8 @@ func (v *fixValidator) Validate(msg *Message) MessageRejectError { return validateFIX(v.dataDictionary, v.settings, msgType, msg) } -//Validate tests the message against the provided transport and app data dictionaries. -//If the message is an admin message, it will be validated against the transport data dictionary. +// Validate tests the message against the provided transport and app data dictionaries. +// If the message is an admin message, it will be validated against the transport data dictionary. func (v *fixtValidator) Validate(msg *Message) MessageRejectError { if !msg.Header.Has(tagMsgType) { return RequiredTagMissing(tagMsgType) diff --git a/validation_test.go b/validation_test.go index 8224c96c0..25a47802a 100644 --- a/validation_test.go +++ b/validation_test.go @@ -466,9 +466,9 @@ func tcTagAppearsMoreThanOnce() validateTest { tag := Tag(40) return validateTest{ - TestName: "Tag appears more than once", - Validator: validator, - MessageBytes: []byte("8=FIX.4.09=10735=D34=249=TW52=20060102-15:04:0556=ISLD11=ID21=140=140=254=138=20055=INTC60=20060102-15:04:0510=234"), + TestName: "Tag appears more than once", + Validator: validator, + MessageBytes: []byte("8=FIX.4.09=10735=D34=249=TW52=20060102-15:04:0556=ISLD11=ID21=140=140=254=138=20055=INTC60=20060102-15:04:0510=234"), ExpectedRejectReason: rejectReasonTagAppearsMoreThanOnce, ExpectedRefTagID: &tag, } @@ -479,9 +479,9 @@ func tcFloatValidation() validateTest { validator := NewValidator(defaultValidatorSettings, dict, nil) tag := Tag(38) return validateTest{ - TestName: "FloatValidation", - Validator: validator, - MessageBytes: []byte("8=FIX.4.29=10635=D34=249=TW52=20140329-22:38:4556=ISLD11=ID21=140=154=138=+200.0055=INTC60=20140329-22:38:4510=178"), + TestName: "FloatValidation", + Validator: validator, + MessageBytes: []byte("8=FIX.4.29=10635=D34=249=TW52=20140329-22:38:4556=ISLD11=ID21=140=154=138=+200.0055=INTC60=20140329-22:38:4510=178"), ExpectedRejectReason: rejectReasonIncorrectDataFormatForValue, ExpectedRefTagID: &tag, }