Skip to content
/ ioctalk Public

Keep transport technology out of your (microservice) business.

License

Notifications You must be signed in to change notification settings

bennil/ioctalk

Repository files navigation

IOC-Talk

Combines dependency injection and remote procedure calls for enterprise architecture implementations without technical dependencies.

Nuget with ShortWireFraming(), LegacyWireFraming() and the serializers: BinaryMessageSerializer(), JsonMessageSerializer()

Nuget with ShortWireFraming() and BinaryMessageSerializer()

Uses .net code generator for communication proxy auto creation and dependency mapping. This is a performance improvement by eliminating runtime code generation and runtime assembly type scanning. The new binary wire format and binary message serializer reduces the transfer size as well.

var localShare = new LocalShareContext();

var tcpMyService = new TcpCommunicationController(new ShortWireFraming(), new JsonMessageSerializer());

var compositionHost = new TalkCompositionHost(localShare, "MyService");

// Maps all transfer interfaces to local implementations or source generated auto implementations
compositionHost.RegisterAutoGeneratedProxyInterfaceMappings();

// Creates a instance of MyServiceImplementation per session
compositionHost.RegisterLocalSessionService<IMyService, MyServiceImplementation>();

// Creates a instance of source generated IMyClientService proxy implementation per session
compositionHost.RegisterRemoteService<IMyClientService>();

// Creates a single instance of MyInternalStuffService (LocalShareContext singleton boundary)
compositionHost.RegisterLocalSharedService<IMyInternalStuffService, MyInternalStuffService>();


compositionHost.InitGenericCommunication(tcpMyService);

// bind to tcp port 14341
tcpMyService.InitService(14341);

If you need to connect to ioctalk legacy wire format services use:

new TcpCommunicationController(new LegacyWireFraming(), new JsonMessageSerializer())
❗ BinaryMessageSerializer is not production ready yet! Binary layout may change due to bugfixes!

Dependency less session handling

How can you react to distributed events (remote endpoint session changes) in your business code without having a dependency to the underlying transfer stack? The ioctalk solution is "constructor out delegate" injection and convention:

Functional service implementation assembly:

	public class MySuperService : IMySuperService
	{
		public MySuperService(out Action<IMySupremeRemoteClientService> clientServiceCreated, 
					out Action<IMySupremeRemoteClientService> clientServiceTerminated)
		{
			clientServiceCreated = OnClientServiceCreated;
			clientServiceTerminated = OnClientServiceTerminated;
		}

		private void OnClientServiceCreated(IMySupremeRemoteClientService client)
		{
			// available remote (or local - depending on the orchestration) client service instance
		}

		private void OnClientServiceTerminated(IMySupremeRemoteClientService client)
		{
		}
	}

By convention the ioctalk dependency injection container needs a "Created" or "Terminated" at the end of the method name.

If your service implementation only manages the single session instance, you can also use an IDisposable implementation to react on session termination. Be aware of not calling remote services in your constructor service implementation. Use constructor parameter (out Action<IMyService> myselfCreated) for remote interaction after the session is ready (all session instances are created).

Now you have separated your business code from any technical dependency. You can use it with ioctalk, within a unit test or some future transfer technology.

Legacy Nuget Packages: ioctalk
ioctalk-AheadOfTimeOnly (No Roslyn dependency required - no auto proxy generation)

About

Keep transport technology out of your (microservice) business.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages