示例#1
0
        public IServer StartWith(Stage stage,
                                 Resources resources, int port, Configuration.SizingConf sizing,
                                 Configuration.TimingConf timing)
        {
            if (!_actor.IsStopped)
            {
                Action <IServer> cons128873 = __ =>
                                              __.StartWith(stage, resources, port, sizing, timing);
                if (_mailbox.IsPreallocated)
                {
                    _mailbox.Send(_actor, cons128873, null, StartWithRepresentation3);
                }
                else
                {
                    _mailbox.Send(new LocalMessage <IServer>(_actor, cons128873,
                                                             StartWithRepresentation3));
                }
            }
            else
            {
                _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, StartWithRepresentation3));
            }

            return(null !);
        }
示例#2
0
        public ServerActor(
            Resources resources,
            Filters filters,
            int port,
            Configuration.SizingConf sizing,
            Configuration.TimingConf timing,
            string channelMailboxTypeName)
        {
            var start = DateExtensions.GetCurrentMillis();

            _filters             = filters;
            _dispatcherPoolIndex = 0;
            _world = Stage.World;
            _requestsMissingContent = new Dictionary <string, RequestResponseHttpContext>();
            _maxMessageSize         = sizing.MaxMessageSize;

            try
            {
                _responseBufferPool = new ConsumerByteBufferPool(
                    ElasticResourcePool <IConsumerByteBuffer, Nothing> .Config.Of(sizing.MaxBufferPoolSize),
                    sizing.MaxMessageSize);

                _dispatcherPool = new IDispatcher[sizing.DispatcherPoolSize];

                for (int idx = 0; idx < sizing.DispatcherPoolSize; ++idx)
                {
                    _dispatcherPool[idx] = Dispatcher.StartWith(Stage, resources);
                }

                _channel =
                    ServerRequestResponseChannelFactory.Start(
                        Stage,
                        Stage.World.AddressFactory.WithHighId(ChannelName),
                        channelMailboxTypeName,
                        this,
                        port,
                        ChannelName,
                        sizing.ProcessorPoolSize,
                        sizing.MaxBufferPoolSize,
                        sizing.MaxMessageSize,
                        timing.ProbeInterval,
                        timing.ProbeTimeout);

                var end = DateExtensions.GetCurrentMillis();

                Logger.Info($"Server {ServerName} is listening on port: {port} started in {end - start} ms");

                _requestMissingContentTimeout = timing.RequestMissingContentTimeout;

                LogResourceMappings(resources);
            }
            catch (Exception e)
            {
                var message = $"Failed to start server because: {e.Message}";
                Logger.Error(message, e);
                throw new InvalidOperationException(message);
            }
        }
示例#3
0
 public IServer StartWith(Stage stage, Resources resources, Filters filters, int port,
                          Configuration.SizingConf sizing, Configuration.TimingConf timing,
                          string severMailboxTypeName, string channelMailboxTypeName) =>
 ServerFactory.StartWith(stage, resources, filters, port, sizing, timing);
示例#4
0
 public IServer StartWith(Stage stage, Resources resources, Filters filters, int port,
                          Configuration.SizingConf sizing, Configuration.TimingConf timing) =>
 ServerFactory.StartWith(stage, resources, filters, port, sizing, timing);
示例#5
0
        public static IServer StartWith(Stage stage, Resources resources, Filters filters, int port, Configuration.SizingConf sizing, Configuration.TimingConf timing, string severMailboxTypeName, string channelMailboxTypeName)
        {
            var server = stage.ActorFor <IServer>(
                Definition.Has <ServerActor>(
                    Definition.Parameters(resources, filters, port, sizing, timing, channelMailboxTypeName),
                    severMailboxTypeName,
                    ServerActor.ServerName),
                stage.World.AddressFactory.WithHighId(),
                stage.World.DefaultLogger);

            server.StartUp();

            return(server);
        }
示例#6
0
 public static IServer StartWith(Stage stage, Resources resources, Filters filters, int port, Configuration.SizingConf sizing, Configuration.TimingConf timing)
 => StartWith(stage, resources, filters, port, sizing, timing, "queueMailbox", "queueMailbox");
示例#7
0
 public static IServer StartWith(Stage stage, Resources resources, int port, Configuration.SizingConf sizing, Configuration.TimingConf timing)
 => StartWith(stage, resources, Filters.None(), port, sizing, timing);
示例#8
0
        public static IServer StartWithAgent(Stage stage, Resources resources, Filters filters, int port, Configuration.SizingConf sizing, string severMailboxTypeName)
        {
            var server = stage.ActorFor <IServer>(
                () => new ServerActor(resources, filters, port, sizing, new Configuration.TimingConf(2, 2, 100), severMailboxTypeName),
                severMailboxTypeName, ServerActor.ServerName, stage.World.AddressFactory.WithHighId(),
                stage.World.DefaultLogger);

            server.StartUp();

            return(server);
        }