Acceptor Dynamic Session Templates (2nd version) #650
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enables
"*"
wildcards in Acceptor's session configuration (forSenderCompID
,SenderSubID
,SenderLocationID
,TargetCompID
,TargetSubID
, andTargetLocationID
).Such session templates can be defined either at start-up or as an ad-hoc operation, just like "normal" sessions.
When processing a new incoming connection, if the incoming
SessionID
is not equal to any of the created sessions, it is then matched vs. templates with wildcards. Upon the first match, the newSession
is created with the same settings as the template ones, just changing wildcards to the actual values from the incomingSessionID
.This PR is an alternative for #607 to address architectural concerns.
Here, instead of changing the
Session
class, I added the newSessionProvider
class, implementing in it most of the logic for creatingSession
s on-the-fly. Change inSocketReader
is to callSessionProvider.GetSession
instead ofSession.LookupSession
.In
ThreadedSocketAcceptor
, the main change is inCreateSession
, to check for wildcards in session settings and do not create such aSession
immediately, but record it as a template while still creatingAcceptorSocketDescriptor
for it. I separated the block of code to do the actual session creation into internalCreateAcceptorSession
, soSessionProvider
can call it when it needs to create a newSession
on-the-fly. PlacingSetSessionSettings
also intoThreadedSocketAcceptor
maybe not the best option; still, it seems to fit OK there to change settings for the entire Acceptor.I tried replacing
static
Session.LookupSession
with alsostatic
SessionProvider.GetSession
, but that seems to be logically incorrect, asThreadedSocketAcceptor
is notstatic
, so theoretically, several of its instances may be created, and then they all will share the sameSessionTemplate
, which does not look correct. SoThreadedSocketAcceptor
has to create aSessionProvider
object, and pass it throughAcceptorSocketDescriptor
->ThreadedSocketReactor
->ClientHandlerThread
toSocketReader
, causing minor changes in all those classes. If you think those changes are not necessary, and there can be only oneThreadedSocketAcceptor
, thenSessionProvider
can be madestatic
. In this case,ThreadedSocketAcceptor
will need to clean up theSessionProvider
on itsStop
(as staticSessionProvider
will keep templates between acceptor stop/start, causing duplication of the templates).Your remarks would be highly appreciated!