Skip to content

Commit

Permalink
Merge branch 'main' into templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ackleymi authored Oct 30, 2023
2 parents 8492960 + 013d9ff commit 656b6d9
Show file tree
Hide file tree
Showing 22 changed files with 172 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM mcr.microsoft.com/vscode/devcontainers/go:0-1.18
FROM mcr.microsoft.com/devcontainers/go:1.21
25 changes: 9 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,22 @@ jobs:
name: Linter
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.18'
- 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
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.50.1'
- name: Run Lint
run: make lint
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51

build:
name: build
runs-on: ubuntu-latest
strategy:
matrix:
go: [1.18]
go: [1.21]
fix-version:
-
- fix40
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ _test/echo_server
_test/tmp
_vendor*
gen
.DS_Store
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## 0.8.1 (October 27, 2023)

BUG FIXES

* Remove initiator wait [GH 587]
* for xml charset and bug of "Incorrect NumInGroup" [GH 368, 363, 365, 366]
* Allow time.Duration or int for timeouts [GH 477]
* Trim extra non-ascii characters that can arise from manually editing [GH 463, 464]

## 0.8.0 (October 25, 2023)

ENHANCEMENTS

* Remove tag from field map [GH 544]
* Add message.Bytes() to avoid string conversion [GH 546]
* Check RejectInvalidMessage on FIXT validation [GH 572]

BUG FIXES

* Fix repeating group read tags lost [GH 462]
* Acceptance test result must be predictable [GH 578]
* Makes event timer stop idempotent [GH 580, 581]
* Added WaitGroup Wait in Initiator [GH 584]

## 0.7.0 (January 2, 2023)

FEATURES
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Open Source [FIX Protocol](http://www.fixprotocol.org/) library implemented in G
<ul>
<li>100% free and open source with a liberal <a href="https://github.com/quickfixgo/quickfix/blob/master/LICENSE.txt">license</a></li>
<li>Supports FIX versions 4.0 - 5.0SP2</li>
<li>Runs on any hardware and operating system supported by Go (1.18+ required)</li>
<li>Runs on any hardware and operating system supported by Go (1.21+ required)</li>
<li>Spec driven run-time message validation</li>
<li>Spec driven code generation of type-safe FIX messages, fields, and repeating groups</li>
<li>Support for protocol customizations</li>
Expand Down
14 changes: 9 additions & 5 deletions _test/ReflectorClient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ def @reflector.waitConnectAction(cid)
end

def @reflector.waitDisconnectAction(cid)
socket = @sockets[cid]
if IO.select([socket], nil, nil, 10) == nil then
raise "Connection hangs after ten seconds."
elsif !socket.eof? then
raise "Expected disconnection, got data"
begin
socket = @sockets[cid]
if IO.select([socket], nil, nil, 10) == nil then
raise "Connection hangs after ten seconds."
elsif !socket.eof? then
raise "Expected disconnection, got data"
end
rescue Errno::ECONNRESET
# Ignore, server has already disconnected the socket
end
end

Expand Down
12 changes: 8 additions & 4 deletions _test/ReflectorServer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ def @reflector.waitConnectAction(cid)
end

def @reflector.waitDisconnectAction(cid)
if IO.select([@socket], nil, nil, 10) == nil then
raise "Connection hangs after five seconds."
elsif !@socket.eof? then
raise "Expected disconnection, got data"
begin
if IO.select([@socket], nil, nil, 10) == nil then
raise "Connection hangs after five seconds."
elsif !@socket.eof? then
raise "Expected disconnection, got data"
end
rescue Errno::ECONNRESET
# Ignore, client has already disconnected the socket
end
end

Expand Down
4 changes: 2 additions & 2 deletions _test/test-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"os/signal"
Expand Down Expand Up @@ -92,7 +92,7 @@ func copyMessage(msg *quickfix.Message) *quickfix.Message {

func main() {
app := &EchoApplication{}
app.log = log.New(ioutil.Discard, "", log.LstdFlags)
app.log = log.New(io.Discard, "", log.LstdFlags)
//app.log = log.New(os.Stdout, "", log.LstdFlags)

router.AddRoute(quickfix.BeginStringFIX40, "D", app.processMsg)
Expand Down
12 changes: 6 additions & 6 deletions cmd/generate-fix/internal/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
printerMode = printer.UseSpaces | printer.TabIndent
)

//ParseError indicates generated go source is invalid
// ParseError indicates generated go source is invalid
type ParseError struct {
path string
err error
Expand All @@ -28,12 +28,12 @@ func (e ParseError) Error() string {
return fmt.Sprintf("Error parsing %v: %v", e.path, e.err)
}

//ErrorHandler is a convenience struct for interpretting generation Errors
// ErrorHandler is a convenience struct for interpretting generation Errors
type ErrorHandler struct {
ReturnCode int
}

//Handle interprets the generation error. Proceeds with setting returnCode, or panics depending on error type
// Handle interprets the generation error. Proceeds with setting returnCode, or panics depending on error type
func (h *ErrorHandler) Handle(err error) {
switch err := err.(type) {
case nil:
Expand Down Expand Up @@ -64,9 +64,9 @@ func write(filePath string, fset *token.FileSet, f *ast.File) error {
return err
}

//WriteFile parses the generated code in fileOut and writes the code out to filePath.
//Function performs some import clean up and gofmts the code before writing
//Returns ParseError if the generated source is invalid but is written to filePath
// WriteFile parses the generated code in fileOut and writes the code out to filePath.
// Function performs some import clean up and gofmts the code before writing
// Returns ParseError if the generated source is invalid but is written to filePath
func WriteFile(filePath, fileOut string) error {
fset := token.NewFileSet()
f, pErr := parser.ParseFile(fset, "", fileOut, parser.ParseComments)
Expand Down
4 changes: 4 additions & 0 deletions datadictionary/datadictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ func Parse(path string) (*DataDictionary, error) {
func ParseSrc(xmlSrc io.Reader) (*DataDictionary, error) {
doc := new(XMLDoc)
decoder := xml.NewDecoder(xmlSrc)
decoder.CharsetReader = func(encoding string, input io.Reader) (io.Reader, error) {
return input, nil
}

if err := decoder.Decode(doc); err != nil {
return nil, errors.Wrapf(err, "problem parsing XML file")
}
Expand Down
13 changes: 11 additions & 2 deletions dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package quickfix
import (
"fmt"
"net"
"time"

"golang.org/x/net/proxy"

Expand All @@ -27,8 +28,16 @@ import (
func loadDialerConfig(settings *SessionSettings) (dialer proxy.Dialer, err error) {
stdDialer := &net.Dialer{}
if settings.HasSetting(config.SocketTimeout) {
if stdDialer.Timeout, err = settings.DurationSetting(config.SocketTimeout); err != nil {
return
timeout, err := settings.DurationSetting(config.SocketTimeout)
if err != nil {
timeoutInt, err := settings.IntSetting(config.SocketTimeout)
if err != nil {
return stdDialer, err
}

stdDialer.Timeout = time.Duration(timeoutInt) * time.Second
} else {
stdDialer.Timeout = timeout
}
}
dialer = stdDialer
Expand Down
12 changes: 6 additions & 6 deletions filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package quickfix
import (
"fmt"
"io"
"io/ioutil"
"os"
"path"
"strconv"
"strings"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -204,24 +204,24 @@ func (store *fileStore) populateCache() (creationTimePopulated bool, err error)
}
}

if timeBytes, err := ioutil.ReadFile(store.sessionFname); err == nil {
if timeBytes, err := os.ReadFile(store.sessionFname); err == nil {
var ctime time.Time
if err := ctime.UnmarshalText(timeBytes); err == nil {
store.cache.creationTime = ctime
creationTimePopulated = true
}
}

if senderSeqNumBytes, err := ioutil.ReadFile(store.senderSeqNumsFname); err == nil {
if senderSeqNum, err := strconv.Atoi(string(senderSeqNumBytes)); err == nil {
if senderSeqNumBytes, err := os.ReadFile(store.senderSeqNumsFname); err == nil {
if senderSeqNum, err := strconv.Atoi(strings.Trim(string(senderSeqNumBytes), "\r\n")); err == nil {
if err = store.cache.SetNextSenderMsgSeqNum(senderSeqNum); err != nil {
return creationTimePopulated, errors.Wrap(err, "cache set next sender")
}
}
}

if targetSeqNumBytes, err := ioutil.ReadFile(store.targetSeqNumsFname); err == nil {
if targetSeqNum, err := strconv.Atoi(string(targetSeqNumBytes)); err == nil {
if targetSeqNumBytes, err := os.ReadFile(store.targetSeqNumsFname); err == nil {
if targetSeqNum, err := strconv.Atoi(strings.Trim(string(targetSeqNumBytes), "\r\n")); err == nil {
if err = store.cache.SetNextTargetMsgSeqNum(targetSeqNum); err != nil {
return creationTimePopulated, errors.Wrap(err, "cache set next target")
}
Expand Down
13 changes: 13 additions & 0 deletions filestore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import (
"fmt"
"os"
"path"
"strconv"
"strings"
"testing"
"time"

assert2 "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
Expand Down Expand Up @@ -62,3 +64,14 @@ func (suite *FileStoreTestSuite) TearDownTest() {
func TestFileStoreTestSuite(t *testing.T) {
suite.Run(t, new(FileStoreTestSuite))
}

func TestStringParse(t *testing.T) {
assert := assert2.New(t)
i, err := strconv.Atoi(strings.Trim("00005\n", "\r\n"))
assert.Nil(err)
assert.Equal(5, i)

i, err = strconv.Atoi(strings.Trim("00006\r", "\r\n"))
assert.Nil(err)
assert.Equal(6, i)
}
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/quickfixgo/quickfix

go 1.18
go 1.21

require (
github.com/armon/go-proxyproto v0.0.0-20210323213023-7e956b284f0a
Expand All @@ -9,7 +9,7 @@ require (
github.com/shopspring/decimal v1.3.1
github.com/stretchr/testify v1.8.4
go.mongodb.org/mongo-driver v1.12.1
golang.org/x/net v0.14.0
golang.org/x/net v0.17.0
)

require (
Expand All @@ -24,9 +24,9 @@ require (
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
Expand All @@ -82,8 +82,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
Expand Down
1 change: 0 additions & 1 deletion initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func (i *Initiator) Start() (err error) {
i.wg.Done()
}(sessionID)
}

return
}

Expand Down
6 changes: 5 additions & 1 deletion internal/event_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type EventTimer struct {
timer *time.Timer
done chan struct{}
wg sync.WaitGroup
once sync.Once
}

func NewEventTimer(task func()) *EventTimer {
Expand Down Expand Up @@ -45,7 +46,10 @@ func (t *EventTimer) Stop() {
return
}

close(t.done)
t.once.Do(func() {
close(t.done)
})

t.wg.Wait()
}

Expand Down
Loading

0 comments on commit 656b6d9

Please sign in to comment.