Skip to content
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

Acceptor Dynamic Session Templates #607

Open
wants to merge 40 commits into
base: master
Choose a base branch
from

Conversation

pvkv1799
Copy link
Contributor

@pvkv1799 pvkv1799 commented Jun 3, 2020

Enables "*" wildcard in Acceptor session configuration (for BeginString, SenderCompID, SenderSubID, SenderLocationID, TargetCompID, TargetSubID, and TargetLocationID).
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 incoming SessionID is not equal to any of the created sessions, it is then matched considering wildcards. If such a match is found, the new session is created with the same settings as the template one, just changing wildcards to the actual values from incoming SessionID.

Copy link
Member

@gbirchmeier gbirchmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, first off, this is going to have some conflicts with #609. That's not a big PR, but it does make a few changes to Session and SessionFactory. I hope to merge #609 today.

I'm not crazy about the acceptor-specific additions to Session. Can we think of any other approach? Making a DynamicSession subclass seems possible off the top of my head, but also could be horrible.

Don't go deep into any big changes yet. I also want to talk to @mgatny and see what ideas he has.

QuickFIXn/Session.cs Outdated Show resolved Hide resolved
/// Calculates unique filename prefix from SessionID.
/// Handles wildcards in SessionID fields
/// </summary>
/// <returns>Filename prefix unique for SessioID</returns>
public static string Prefix(SessionID sessionID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly (or all) the same as FileStore.Prefix(). That was fine when they were small, but now I think this common code should be unified. Perhaps a static class & function would be appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do - should I put the new calls in "Util" subfolder of the solution?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll work, or it could go in the same dir as FileLog/FileStore. Doesn't really matter to me.

QuickFIXn/Session.cs Show resolved Hide resolved
QuickFIXn/SessionSettings.cs Outdated Show resolved Hide resolved
public Session(
IApplication app, IMessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
SessionSchedule sessionSchedule, int heartBtInt, ILogFactory logFactory, IMessageFactory msgFactory, string senderDefaultApplVerID,
IAcceptor acceptor, QuickFix.Dictionary settings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not terribly comfortable seeing _acceptor here given how this class isn't really acceptor-specific, but I don't have a better idea. Not totally sure about settings also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both _acceptor and _settings are required to create the new "real" session when connecting to a template session. However, as noted in the beginning, it may not be the best solution and might be replaced with adding a SessionTemplate class. What, in turn, then seemingly requires more changes to the logic of accepting connections and looking up existing sessions...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I get that. I just don't like the resulting architecture. I'll think about it, see if any brainstorms come to me...

QuickFIXn/Session.cs Outdated Show resolved Hide resolved
{
throw new ConfigError(BEGINSTRING + " (" + beginString + ") must be FIX.4.0 to FIX.4.4 or FIXT.1.1");
throw new ConfigError($"{BEGINSTRING} ({ beginString }) must be FIX.4.0 to FIX.4.4 or FIXT.1.1 or wildcard '{Values.WILDCARD_VALUE}' (only for acceptor)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we wildcard the begin string? An acceptor can only service one FIX version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got "inspired" by simpleacc.cfg, where one acceptor has several [SESSION] with different BeginString. Now, at second glance, I realize that DataDictionary needs to also be dynamically adjusted to BeginString, and that would probably be complicated to solve, but not really worth it... So I would agree to remove wildcard support for BeginString parameter.

QuickFIXn/Session.cs Outdated Show resolved Hide resolved
UnitTests/SessionSettingsTest.cs Outdated Show resolved Hide resolved
@pvkv1799
Copy link
Contributor Author

Ok, first off, this is going to have some conflicts with #609. That's not a big PR, but it does make a few changes to Session and SessionFactory. I hope to merge #609 today.

Fine, I will merge #609 into this PR as well (after you).

I'm not crazy about the acceptor-specific additions to Session. Can we think of any other approach? Making a DynamicSession subclass seems possible off the top of my head, but also could be horrible.

I did start with a new DynamicSession class but then realized that it would require more complicated changes than "simply" replacing LookupSession with LookupOrCreateSession (now called GetSession), so decided for a quicker solution.
I agree that this is (to a certain extent) a misuse of Session class, and could adjust the implementation following your architectural advice.

Don't go deep into any big changes yet. I also want to talk to @mgatny and see what ideas he has.

OK, I would wait for your further advice before making the suggested changes.

Thank you!

@gbirchmeier
Copy link
Member

FYI, #609 is in master now, so at your leisure you can upmerge or rebase.

@pvkv1799
Copy link
Contributor Author

pvkv1799 commented Jun 16, 2020 via email

@gbirchmeier
Copy link
Member

Haven't had time to think about reworking the impl yet, but for now maybe just resolve the conflicts.

@pvkv1799
Copy link
Contributor Author

OK, will resolve

Catching up with the original master
@pvkv1799
Copy link
Contributor Author

Conflicts resolved, and some of the suggested fixes made (marked them resolved). The rest will do after decision on the architecture.
Thank you!

@pvkv1799
Copy link
Contributor Author

@gbirchmeier Apologies - have you had a chance to think about the architecture? I could do the changes if you have a better solution in mind.
Thank you!

@CLAassistant
Copy link

CLAassistant commented Aug 12, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
3 out of 4 committers have signed the CLA.

✅ pvkv1799
✅ LittleAlexey
✅ gbirchmeier
❌ dependabot-preview[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants