Skip to content

Commit 36647e3

Browse files
authored
Merge branch 'main' into fix/sequence_number_bug
2 parents b85ce2b + 01702d7 commit 36647e3

File tree

12 files changed

+1175
-378
lines changed

12 files changed

+1175
-378
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
strategy:
3838
matrix:
3939
go: [1.21]
40+
store-type:
41+
- memory
42+
- file
4043
fix-version:
4144
-
4245
- fix40
@@ -67,4 +70,5 @@ jobs:
6770
GO111MODULE: on
6871
MONGODB_TEST_CXN: mongodb://localhost:27017
6972
FIX_TEST: ${{ matrix.fix-version }}
73+
STORE_TYPE: ${{ matrix.store-type }}
7074
run: if [ -z $FIX_TEST ]; then make build-src && make test-ci; else make generate-ci && make build && make $FIX_TEST; fi

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ lint: linters-install
3131
build-test-srv:
3232
cd _test; go build -o echo_server ./test-server/
3333
fix40:
34-
cd _test; ./runat.sh $@.cfg 5001 "definitions/server/$@/*.def"
34+
cd _test; ./runat.sh $@.cfg 5001 $(STORE_TYPE) "definitions/server/$@/*.def"
3535
fix41:
36-
cd _test; ./runat.sh $@.cfg 5002 "definitions/server/$@/*.def"
36+
cd _test; ./runat.sh $@.cfg 5002 $(STORE_TYPE) "definitions/server/$@/*.def"
3737
fix42:
38-
cd _test; ./runat.sh $@.cfg 5003 "definitions/server/$@/*.def"
38+
cd _test; ./runat.sh $@.cfg 5003 $(STORE_TYPE) "definitions/server/$@/*.def"
3939
fix43:
40-
cd _test; ./runat.sh $@.cfg 5004 "definitions/server/$@/*.def"
40+
cd _test; ./runat.sh $@.cfg 5004 $(STORE_TYPE) "definitions/server/$@/*.def"
4141
fix44:
42-
cd _test; ./runat.sh $@.cfg 5005 "definitions/server/$@/*.def"
42+
cd _test; ./runat.sh $@.cfg 5005 $(STORE_TYPE) "definitions/server/$@/*.def"
4343
fix50:
44-
cd _test; ./runat.sh $@.cfg 5006 "definitions/server/$@/*.def"
44+
cd _test; ./runat.sh $@.cfg 5006 $(STORE_TYPE) "definitions/server/$@/*.def"
4545
fix50sp1:
46-
cd _test; ./runat.sh $@.cfg 5007 "definitions/server/$@/*.def"
46+
cd _test; ./runat.sh $@.cfg 5007 $(STORE_TYPE) "definitions/server/$@/*.def"
4747
fix50sp2:
48-
cd _test; ./runat.sh $@.cfg 5008 "definitions/server/$@/*.def"
48+
cd _test; ./runat.sh $@.cfg 5008 $(STORE_TYPE) "definitions/server/$@/*.def"
4949

5050
ACCEPT_SUITE=fix40 fix41 fix42 fix43 fix44 fix50 fix50sp1 fix50sp2
5151
accept: $(ACCEPT_SUITE)

_test/runat.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
CFG=$1
44
PORT=$2
5-
TESTS=$3
5+
STORETYPE=$3
6+
TESTS=$4
67

7-
./echo_server $CFG &
8+
./echo_server $CFG $STORETYPE &
89
pid=$!
910

1011
ruby -I. Runner.rb 127.0.0.1 $PORT $TESTS

_test/test-server/main.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ import (
77
"log"
88
"os"
99
"os/signal"
10+
"path"
11+
"strings"
12+
"time"
1013

1114
"github.com/quickfixgo/quickfix"
15+
"github.com/quickfixgo/quickfix/config"
1216
field "github.com/quickfixgo/quickfix/gen/field"
1317
tag "github.com/quickfixgo/quickfix/gen/tag"
1418
)
@@ -131,7 +135,21 @@ func main() {
131135
return
132136
}
133137

134-
acceptor, err := quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory)
138+
storeType := os.Args[2]
139+
140+
var acceptor *quickfix.Acceptor
141+
switch strings.ToUpper(storeType) {
142+
case "FILE":
143+
fileStoreRootPath := path.Join(os.TempDir(), fmt.Sprintf("FileStoreTestSuite-%d", os.Getpid()))
144+
fileStorePath := path.Join(fileStoreRootPath, fmt.Sprintf("%d", time.Now().UnixNano()))
145+
appSettings.GlobalSettings().Set(config.FileStorePath, fileStorePath)
146+
acceptor, err = quickfix.NewAcceptor(app, quickfix.NewFileStoreFactory(appSettings), appSettings, fileLogFactory)
147+
case "MEMORY":
148+
acceptor, err = quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory)
149+
default:
150+
acceptor, err = quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory)
151+
}
152+
135153
if err != nil {
136154
fmt.Println("Unable to create Acceptor: ", err)
137155
return

config/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const (
3535
EndTime string = "EndTime"
3636
StartDay string = "StartDay"
3737
EndDay string = "EndDay"
38+
Weekdays string = "Weekdays"
3839
TimeZone string = "TimeZone"
3940
DataDictionary string = "DataDictionary"
4041
TransportDataDictionary string = "TransportDataDictionary"

config/doc.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,22 @@ Time of day that this FIX session becomes deactivated. Valid Values:
8484
8585
# StartDay
8686
87-
For week long sessions, the starting day of week for the session. Use in combination with StartTime. Valid Values:
87+
For week long sessions, the starting day of week for the session. Use in combination with StartTime. Incompatible with Weekdays. Valid Values:
8888
8989
Full day of week in English, or 3 letter abbreviation (i.e. Monday and Mon are valid)
9090
9191
# EndDay
9292
93-
For week long sessions, the ending day of week for the session. Use in combination with EndTime. Valid Values:
93+
For week long sessions, the ending day of week for the session. Use in combination with EndTime. Incompatible with Weekdays. Valid Values:
9494
9595
Full day of week in English, or 3 letter abbreviation (i.e. Monday and Mon are valid)
9696
97+
# Weekdays
98+
99+
For daily sessions that are only active on specific days of the week. Use in combination with StartTime and EndTime. Incompatible with StartDay and EndDay. Valid Values:
100+
101+
Comma delimited list of days of the week in English, or 3 letter abbreviation (e.g. "Monday,Tuesday,Wednesday" or "Mon,Tue,Wed" would both be valid values).
102+
97103
# EnableLastMsgSeqNumProcessed
98104
99105
Add the last message sequence number processed in the header (optional tag 369). Valid Values:

filestore.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ func (f fileStoreFactory) Create(sessionID SessionID) (msgStore MessageStore, er
7676

7777
dirname, err := sessionSettings.Setting(config.FileStorePath)
7878
if err != nil {
79-
return nil, err
79+
dirname, err = globalSettings.Setting(config.FileStorePath)
80+
if err != nil {
81+
return nil, err
82+
}
8083
}
8184
var fsync bool
8285
if sessionSettings.HasSetting(config.FileStoreSync) {

internal/time_range.go

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,67 @@ func ParseTimeOfDay(str string) (TimeOfDay, error) {
3636
// TimeRange represents a time band in a given time zone.
3737
type TimeRange struct {
3838
startTime, endTime TimeOfDay
39+
weekdays []time.Weekday
3940
startDay, endDay *time.Weekday
4041
loc *time.Location
4142
}
4243

4344
// NewUTCTimeRange returns a time range in UTC.
44-
func NewUTCTimeRange(start, end TimeOfDay) *TimeRange {
45-
return NewTimeRangeInLocation(start, end, time.UTC)
45+
func NewUTCTimeRange(start, end TimeOfDay, weekdays []time.Weekday) (*TimeRange, error) {
46+
return NewTimeRangeInLocation(start, end, weekdays, time.UTC)
4647
}
4748

4849
// NewTimeRangeInLocation returns a time range in a given location.
49-
func NewTimeRangeInLocation(start, end TimeOfDay, loc *time.Location) *TimeRange {
50+
func NewTimeRangeInLocation(start, end TimeOfDay, weekdays []time.Weekday, loc *time.Location) (*TimeRange, error) {
51+
5052
if loc == nil {
51-
panic("time: missing Location in call to NewTimeRangeInLocation")
53+
return nil, errors.New("time: missing Location in call to NewTimeRangeInLocation")
5254
}
5355

54-
return &TimeRange{startTime: start, endTime: end, loc: loc}
56+
return &TimeRange{
57+
startTime: start,
58+
endTime: end,
59+
weekdays: weekdays,
60+
loc: loc,
61+
}, nil
5562
}
5663

5764
// NewUTCWeekRange returns a weekly TimeRange.
58-
func NewUTCWeekRange(startTime, endTime TimeOfDay, startDay, endDay time.Weekday) *TimeRange {
65+
func NewUTCWeekRange(startTime, endTime TimeOfDay, startDay, endDay time.Weekday) (*TimeRange, error) {
5966
return NewWeekRangeInLocation(startTime, endTime, startDay, endDay, time.UTC)
6067
}
6168

6269
// NewWeekRangeInLocation returns a time range in a given location.
63-
func NewWeekRangeInLocation(startTime, endTime TimeOfDay, startDay, endDay time.Weekday, loc *time.Location) *TimeRange {
64-
r := NewTimeRangeInLocation(startTime, endTime, loc)
70+
func NewWeekRangeInLocation(startTime, endTime TimeOfDay, startDay, endDay time.Weekday, loc *time.Location) (*TimeRange, error) {
71+
r, err := NewTimeRangeInLocation(startTime, endTime, []time.Weekday{}, loc)
72+
if err != nil {
73+
return nil, err
74+
}
6575
r.startDay = &startDay
6676
r.endDay = &endDay
6777

68-
return r
78+
return r, nil
6979
}
7080

7181
func (r *TimeRange) isInTimeRange(t time.Time) bool {
7282
t = t.In(r.loc)
7383
ts := NewTimeOfDay(t.Clock()).d
7484

85+
if len(r.weekdays) > 0 {
86+
found := false
87+
88+
for _, weekday := range r.weekdays {
89+
if t.Weekday() == weekday {
90+
found = true
91+
break
92+
}
93+
}
94+
95+
if !found {
96+
return false
97+
}
98+
}
99+
75100
if r.startTime.d < r.endTime.d {
76101
return r.startTime.d <= ts && ts <= r.endTime.d
77102
}

0 commit comments

Comments
 (0)