public void Regex_based_matching(string source, string target, string streamId, string actorId) { var system = new ActorSystemMock(); var attribute = new StreamSubscriptionAttribute { Source = source, Target = target }; var type = typeof(TestActor); var dispatcher = new Dispatcher(type); var specification = StreamSubscriptionSpecification.From(type, attribute, dispatcher); specification.Type = ActorTypeName.Of(typeof(TestActor)); var match = specification.Match(system, streamId); if (match == StreamSubscriptionMatch.None) { Assert.That(actorId, Is.Null); return; } var message = new object(); match.Receiver(message); Assert.That(system.RequestedRef, Is.Not.Null); Assert.That(system.RequestedRef.Path, Is.EqualTo(typeof(TestActor).ToActorPath(actorId))); Assert.That(system.RequestedRef.MessagePassedToTell, Is.SameAs(message)); }
internal static void Reset() { ActorTypeName.Reset(); Activator = new DefaultActorActivator(); dispatchers.Clear(); Conventions = null; }
public static ActorPath ToActorPath(this Type type, string id) { Requires.NotNull(type, nameof(type)); var key = ActorTypeName.Of(type); return(ActorPath.From(key, id)); }
static EndpointConfiguration BuildInterface(Type actor) { if (ActorTypeName.IsRegistered(actor)) { return(null); // assume endpoint was already build from implementation } return(new ActorConfiguration(ActorTypeName.Register(actor))); }
StreamSubscriptionSpecification(Type actor, string provider, Func <string, string> matcher, Func <object, string> selector = null, Func <object, bool> filter = null) { Requires.NotNullOrWhitespace(provider, nameof(provider)); Requires.NotNull(matcher, nameof(matcher)); Type = ActorTypeName.Of(actor); Provider = provider; this.matcher = matcher; this.selector = selector; this.filter = filter ?? (x => true); }
static EndpointConfiguration BuildWorker(Type worker) { var config = new WorkerConfiguration(ActorTypeName.Register(worker)); SetReentrancy(worker, config); SetKeepAliveTimeout(worker, config); SetReceiver(worker, config); SetAutorun(worker, config); SetStickiness(worker, config); SetInvoker(worker, config); return(config); }
static EndpointConfiguration BuildActor(Type actor) { var config = new ActorConfiguration(ActorTypeName.Register(actor)); SetPlacement(actor, config); SetReentrancy(actor, config); SetKeepAliveTimeout(actor, config); SetReceiver(actor, config); SetAutorun(actor, config); SetStickiness(actor, config); SetInvoker(actor, config); return(config); }
void RegisterAutoruns() { var autoruns = new Dictionary <string, string[]>(); foreach (var actor in assemblies.SelectMany(x => x.ActorTypes())) { var ids = AutorunAttribute.From(actor); if (ids.Length > 0) { autoruns.Add(ActorTypeName.Of(actor), ids); } } Bootstrapper <AutorunBootstrapper>(autoruns); }
public void Dynamic_target_matching() { var system = new ActorSystemMock(); var type = typeof(DynamicTargetSelectorActor); var dispatcher = new Dispatcher(type); var specification = StreamSubscriptionSpecification.From(type, dispatcher).ElementAt(0); specification.Type = ActorTypeName.Of(typeof(DynamicTargetSelectorActor)); var match = specification.Match(system, "foo"); var message = new object(); match.Receiver(message); Assert.That(system.RequestedRef, Is.Not.Null); Assert.That(system.RequestedRef.Path, Is.EqualTo(typeof(DynamicTargetSelectorActor).ToActorPath("bar"))); Assert.That(system.RequestedRef.MessagePassedToTell, Is.SameAs(message)); }