public static T Add <T>(this IRootContext @this, Func <T> create) where T : ISerializerExtension { var result = create(); @this.Add(result); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="EventStore"/> class. /// </summary> /// <param name="getEventStoreClient">The factory to use to get the <see cref="EventStoreActor"/> client.</param> /// <param name="logger">The logger to use for logging.</param> /// <param name="getCommittedEventsFetcher"></param> /// <param name="rootContext">Proto root context. Allows middleware to be used</param> public EventStore(Func <TenantId, EventStoreClient> getEventStoreClient, ILogger logger, Func <TenantId, IFetchCommittedEvents> getCommittedEventsFetcher, IRootContext rootContext) { _getEventStoreClient = getEventStoreClient; _logger = logger; _getCommittedEventsFetcher = getCommittedEventsFetcher; _rootContext = rootContext; }
public RequestContext(string connectionString) { var mapperConfig = new DefaultMapperConfig().Configure(); var mapper1 = mapperConfig.CreateMapper(); RootContext = new RootContext(connectionString, mapper1); }
internal PartitionManager(Cluster cluster, bool isClient, TimeSpan identityHandoverTimeout) { _cluster = cluster; _system = cluster.System; _context = _system.Root; _isClient = isClient; _identityHandoverTimeout = identityHandoverTimeout; }
/// <summary> /// Used to extend a root context (usually a configuration container). This passes in a collection of extensions to /// add to the context's collection of serializer extensions. /// </summary> /// <param name="this">The root context that contains the target collection of serializer extensions.</param> /// <param name="extensions">The array of extensions to add.</param> /// <returns>The configured context (usually a configuration container).</returns> public static IRootContext Extend(this IRootContext @this, params ISerializerExtension[] extensions) { var items = @this.TypeZip(extensions).ToList(); @this.Clear(); items.ForEach(@this.Add); return(@this); }
public ProtoActorHostedService(IServiceProvider serviceProvider, IRootContext root, ProtoActorHostedServiceStart protoActorHostedServiceStart) { ServiceProvider = serviceProvider; Root = root; ProtoActorHostedServiceStart = protoActorHostedServiceStart; }
public static IRootContext With <T>(this IRootContext @this, Action <T> configure) where T : class, ISerializerExtension { var extension = @this.With <T>(); configure(extension); return(@this); }
public OpenTracingRootContextDecorator(IRootContext context, SpanSetup sendSpanSetup, ITracer tracer) : base(context) { _sendSpanSetup = (span, message) => { ProtoTags.ActorType.Set(span, "<None>"); sendSpanSetup(span, message); }; _tracer = tracer; }
public static IRootContext Apply <T>(this IRootContext @this, Func <T> create) where T : class, ISerializerExtension { if ([email protected] <T>()) { @this.Add(create); } return(@this); }
//public EFUnitOfWork(string connectionString) //{ // context = new ApplicationContext(connectionString); // userManager = new ApplicationUserManager(new UserStore<User>(context)); // roleManager = new ApplicationRoleManager(new RoleStore<UserRole>(context)); // clientManager = new ClientManager(context); // calendarRepository = new GenericRepository<Calendar>(context); //} public EFUnitOfWork(IRootContext cont) { context = new ApplicationContext(cont.ConnectionString); userManager = new ApplicationUserManager(new UserStore <User>(context)); roleManager = new ApplicationRoleManager(new RoleStore <UserRole>(context)); //clientManager = new ClientManager(context); calendarRepository = new GenericRepository <Calendar>(context); eventinfoRepository = new GenericRepository <EventInfo>(context); eventRepository = new GenericRepository <Event>(context); groupRepository = new GenericRepository <Group>(context); repinfoRepository = new GenericRepository <RepeatInfo>(context); }
private static async Task DoClientWork(Remote client, IRootContext context) { var index = 0; var verbs = new List <string>() { "Get", "Put", "Post" }; var random = new Random(); var lastKey = ""; PID pid = null; // example of calling grains from the initialized client while (true) { var currentTime = DateTimeOffset.Now.ToString("g"); var metric = "latency"; var currentKey = $"test!{currentTime}!{metric}"; if (currentKey != lastKey) { // This can be expensive var result = await client.SpawnNamedAsync("127.0.0.1:8000", currentKey, "record", TimeSpan.FromMinutes(30)); pid = result.Pid; lastKey = currentKey; } index++; if (index % 10_000 == 0) { System.Threading.Thread.Sleep(100); Console.WriteLine(index); } var r = new Record() { Service = "test", Time = (ulong)DateTimeOffset.Now.Ticks, Metricvalue = 10 }; r.Attributes.Add("Verb", verbs[random.Next(0, 3)]); context.Send(pid, r); } }
public ActorManager(IActorFactory actorFactory, IProvider persistenceProvider, IOptions <ActorSettings> actorSettings, ITracer tracer, ILoggerFactory loggerFactory) { _actorFactory = actorFactory; var settings = actorSettings.Value; var logger = loggerFactory.CreateLogger <ActorManager>(); // Configure OpenTracing Context = new RootContext(new MessageHeader(), OpenTracingExtensions.OpenTracingSenderMiddleware()) .WithOpenTracing(); _actorFactory.RegisterActor(new RequestActor(this, persistenceProvider, TimeSpan.FromMilliseconds(settings.ChildActorTimeoutInMilliseconds), loggerFactory, tracer), ActorNames.RequestActor); EventStream.Instance.Subscribe <DeadLetterEvent>(dl => { logger.LogWarning($"DeadLetter from {dl.Sender} to {dl.Pid} : {dl.Message?.GetType().Name} = '{dl.Message?.ToString()}'"); }); }
protected RootContextDecorator(IRootContext context) { _context = context; }
public static T Add <T>(this IRootContext @this) where T : ISerializerExtension => Add(@this, Support <T> .NewOrSingleton);
public BusinessContext(IRootContext context) { RootContext = context; }
public static IRootContext EnableReferences(this IRootContext @this) { @this.EnableRootInstances() .With <ReferencesExtension>(); return(@this); }
public static IRootContext Apply <T>(this IRootContext @this) where T : class, ISerializerExtension => Apply(@this, Support <T> .NewOrSingleton);
public TypeConfiguration(IRootContext root, IProperty <string> name) : this(root, name, new MemberConfigurations <T>(new TypeConfigurationContext(root, Support <T> .Metadata))) { }
public TypeConfiguration(IRootContext context, IProperty <string> name, IMemberConfigurations members) : base(context) { _name = name; _members = members; }
public BaseService(IRootContext context) { Context = new BusinessContext(context); }
public static IPropsFactory <T> PropsFactory <T>(this IRootContext context) where T : IActor => context.System.ServiceProvider().GetRequiredService <IPropsFactory <T> >();
public PropsFactoryWithOpenTelemetry(IRootContext rootContext, IServiceProvider serviceProvider) { RootContext = rootContext; ServiceProvider = serviceProvider; }
public HelloController(IRootContext actorRoot, ILogger <HelloController> logger) { Root = actorRoot; Logger = logger; }
public RootActorSteps(ScenarioContext scenario, IRootContext root, IUserContext user) { this.root = root; this.user = user; this.scenario = scenario; }
public static T With <T>(this IRootContext @this) where T : class, ISerializerExtension => @this.Find <T>() ?? @this.Add <T>();
public LoggingRootDecorator(IRootContext context) : base(context) { }
public AuthorService(IRootContext context) : base(context) { }
public RootContextExtension(IRootContext root) => Root = root;
public Task Invoke(IRootContext context, Func <IRootContext, Task> next) { return(TaskEx.CompletedTask); }
public BookRepository(IRootContext context) : base(context) { }