Ejemplo n.º 1
0
        public static T Add <T>(this IRootContext @this, Func <T> create) where T : ISerializerExtension
        {
            var result = create();

            @this.Add(result);
            return(result);
        }
Ejemplo n.º 2
0
 /// <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;
 }
Ejemplo n.º 3
0
        public RequestContext(string connectionString)
        {
            var mapperConfig = new DefaultMapperConfig().Configure();
            var mapper1      = mapperConfig.CreateMapper();

            RootContext = new RootContext(connectionString, mapper1);
        }
Ejemplo n.º 4
0
 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);
        }
Ejemplo n.º 6
0
 public ProtoActorHostedService(IServiceProvider serviceProvider,
                                IRootContext root,
                                ProtoActorHostedServiceStart protoActorHostedServiceStart)
 {
     ServiceProvider = serviceProvider;
     Root            = root;
     ProtoActorHostedServiceStart = protoActorHostedServiceStart;
 }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 9
0
 public static IRootContext Apply <T>(this IRootContext @this, Func <T> create)
     where T : class, ISerializerExtension
 {
     if ([email protected] <T>())
     {
         @this.Add(create);
     }
     return(@this);
 }
Ejemplo n.º 10
0
 //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);
 }
Ejemplo n.º 11
0
        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()}'");
            });
        }
Ejemplo n.º 13
0
 protected RootContextDecorator(IRootContext context)
 {
     _context = context;
 }
Ejemplo n.º 14
0
 public static T Add <T>(this IRootContext @this) where T : ISerializerExtension
 => Add(@this, Support <T> .NewOrSingleton);
Ejemplo n.º 15
0
 public BusinessContext(IRootContext context)
 {
     RootContext = context;
 }
Ejemplo n.º 16
0
 public static IRootContext EnableReferences(this IRootContext @this)
 {
     @this.EnableRootInstances()
     .With <ReferencesExtension>();
     return(@this);
 }
Ejemplo n.º 17
0
 public static IRootContext Apply <T>(this IRootContext @this)
     where T : class, ISerializerExtension => Apply(@this, Support <T> .NewOrSingleton);
Ejemplo n.º 18
0
 public TypeConfiguration(IRootContext root, IProperty <string> name)
     : this(root, name, new MemberConfigurations <T>(new TypeConfigurationContext(root, Support <T> .Metadata)))
 {
 }
Ejemplo n.º 19
0
 public TypeConfiguration(IRootContext context, IProperty <string> name, IMemberConfigurations members)
     : base(context)
 {
     _name    = name;
     _members = members;
 }
Ejemplo n.º 20
0
 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;
 }
Ejemplo n.º 23
0
 public HelloController(IRootContext actorRoot,
                        ILogger <HelloController> logger)
 {
     Root   = actorRoot;
     Logger = logger;
 }
Ejemplo n.º 24
0
 public RootActorSteps(ScenarioContext scenario, IRootContext root, IUserContext user)
 {
     this.root     = root;
     this.user     = user;
     this.scenario = scenario;
 }
Ejemplo n.º 25
0
 public static T With <T>(this IRootContext @this) where T : class, ISerializerExtension
 => @this.Find <T>() ?? @this.Add <T>();
Ejemplo n.º 26
0
 public LoggingRootDecorator(IRootContext context) : base(context)
 {
 }
Ejemplo n.º 27
0
 public AuthorService(IRootContext context) : base(context)
 {
 }
Ejemplo n.º 28
0
 public RootContextExtension(IRootContext root) => Root = root;
Ejemplo n.º 29
0
 public Task Invoke(IRootContext context, Func <IRootContext, Task> next)
 {
     return(TaskEx.CompletedTask);
 }
Ejemplo n.º 30
0
 public BookRepository(IRootContext context) : base(context)
 {
 }