Skip to content

Change ResetSeqTime to time.Time based on the config's timeZone #712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/session_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ type SessionSettings struct {
SkipCheckLatency bool
MaxLatency time.Duration
DisableMessagePersist bool
ResetSeqTime TimeOfDay
TimeZone *time.Location
ResetSeqTime time.Time
EnableResetSeqTime bool

// Required on logon for FIX.T.1 messages.
Expand Down
9 changes: 6 additions & 3 deletions session_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type sessionFactory struct {
BuildInitiators bool
}

const shortForm = "15:04:05"

// Creates Session, associates with internal session registry.
func (f sessionFactory) createSession(
sessionID SessionID, storeFactory MessageStoreFactory, settings *SessionSettings,
Expand Down Expand Up @@ -280,6 +282,7 @@ func (f sessionFactory) newSession(
return
}
}
s.TimeZone = loc

if !settings.HasSetting(config.StartDay) && !settings.HasSetting(config.EndDay) {
var weekdays []time.Weekday
Expand Down Expand Up @@ -354,11 +357,11 @@ func (f sessionFactory) newSession(
return
}

var seqTime internal.TimeOfDay
if seqTime, err = internal.ParseTimeOfDay(seqTimeStr); err != nil {
var seqTime time.Time
if seqTime, err = time.ParseInLocation(shortForm, seqTimeStr, s.TimeZone); err != nil {
err = errors.Wrapf(
err, "problem parsing time of day '%v' for setting '%v",
settings.settings[config.StartTime], config.StartTime,
settings.settings[config.ResetSeqTime], config.ResetSeqTime,
)
return
}
Expand Down
5 changes: 3 additions & 2 deletions session_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ func (sm *stateMachine) CheckSessionTime(session *session, now time.Time) {

func (sm *stateMachine) CheckResetTime(session *session, now time.Time) {
if session.EnableResetSeqTime {
ts := internal.NewTimeOfDay(now.Clock())
if session.ResetSeqTime == ts {
if session.ResetSeqTime.Hour() == now.Hour() &&
session.ResetSeqTime.Minute() == now.Minute() &&
session.ResetSeqTime.Second() == now.Second() {
session.sendLogonInReplyTo(true, nil)
}
}
Expand Down
2 changes: 1 addition & 1 deletion session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ func (s *SessionSuite) TestSeqNumResetTime() {
s.SetupTest()

now := time.Now().UTC()
s.session.ResetSeqTime = internal.NewTimeOfDay(now.Clock())
s.session.ResetSeqTime = now
s.session.EnableResetSeqTime = true

s.IncrNextSenderMsgSeqNum()
Expand Down
Loading