Acceptor Dynamic Session Templates (2nd version)#650
Acceptor Dynamic Session Templates (2nd version)#650pvkv1799 wants to merge 4 commits intoconnamara:masterfrom
Conversation
|
It's very nice PR. public inteface ISessionProvider {
Session GetSession(SessionID sessionID);
}Use SessionProvider instead of SessionProvider every where public Session GetSession(SessionID sessionID)
{
Session session = Session.LookupSession(sessionID);
return session;
} |
|
@SenyaMur - thank you for the ideas, however there is an issue with changing it to an interface.
the interface has also to provide void AddTemplate(SessionID sessionID, Dictionary dict, ThreadedSocketAcceptor acceptor, AcceptorSocketDescriptor descriptor)to be used in I do not feel right to change @gbirchmeier, @mgatny : could you please advise regarding the proposed change? I would highly appreciate your feedback on this PR. Thank you! |
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
SessionIDis not equal to any of the created sessions, it is then matched vs. templates with wildcards. Upon the first match, the newSessionis 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
Sessionclass, I added the newSessionProviderclass, implementing in it most of the logic for creatingSessions on-the-fly. Change inSocketReaderis to callSessionProvider.GetSessioninstead ofSession.LookupSession.In
ThreadedSocketAcceptor, the main change is inCreateSession, to check for wildcards in session settings and do not create such aSessionimmediately, but record it as a template while still creatingAcceptorSocketDescriptorfor it. I separated the block of code to do the actual session creation into internalCreateAcceptorSession, soSessionProvidercan call it when it needs to create a newSessionon-the-fly. PlacingSetSessionSettingsalso intoThreadedSocketAcceptormaybe not the best option; still, it seems to fit OK there to change settings for the entire Acceptor.I tried replacing
staticSession.LookupSessionwith alsostaticSessionProvider.GetSession, but that seems to be logically incorrect, asThreadedSocketAcceptoris notstatic, so theoretically, several of its instances may be created, and then they all will share the sameSessionTemplate, which does not look correct. SoThreadedSocketAcceptorhas to create aSessionProviderobject, and pass it throughAcceptorSocketDescriptor->ThreadedSocketReactor->ClientHandlerThreadtoSocketReader, causing minor changes in all those classes. If you think those changes are not necessary, and there can be only oneThreadedSocketAcceptor, thenSessionProvidercan be madestatic. In this case,ThreadedSocketAcceptorwill need to clean up theSessionProvideron itsStop(as staticSessionProviderwill keep templates between acceptor stop/start, causing duplication of the templates).Your remarks would be highly appreciated!