Ejemplo n.º 1
0
        public static ISignalsHub New(SignalsConfig config = null)
        {
            config = config ?? new SignalsConfig();

            return
                new SignalsHub(config);
        }
Ejemplo n.º 2
0
        private SignalsHub(SignalsConfig config)
        {
            _counters = new Counters();
            var ioc = create_dependencies(config);

            _log = ioc.Resolve<ILogFile>();
            _repo = ioc.Resolve<IHubRepo>();
            _configRa = ioc.Resolve<ISignalsConfigRa>();
            _messenger = ioc.Resolve<IMessengerEngine>();
            _agents = ioc.Resolve<IAgentsEngine>();
            _idler = ioc.Resolve<IIdler>();
            _scheduler = ioc.Resolve<IEventScheduler>();

            var target = wcf.SignalsHub.New(this);
            _host = WcfHost<comm.ISignalsHub>.NewAsync(_log, target);
            _serviceName = GetType().AsServiceName();
        }
Ejemplo n.º 3
0
        private MessengerEngine(IIoC ioc)
        {
            _msg2failureHandler = new Dictionary<Type, Action<comm.IoMsg>> {
                {typeof(comm.PublishMsg), msg => update_failure_counters((comm.PublishMsg) msg)},
                {typeof(comm.FilterInfo), msg => update_failure_counters((comm.FilterInfo) msg)},
                {typeof(comm.TopicFilterMsg), msg => update_failure_counters((comm.TopicFilterMsg) msg)},
                {typeof(comm.HeartbeatMsg), msg => update_failure_counters((comm.HeartbeatMsg) msg)}
            };

            _counters = new Counters();
            _configRa = ioc.Resolve<ISignalsConfigRa>();

            var config = _configRa.Values;
            _cachedConfig = config;
            _log = ThrottledLog.NewSync(config.ThrottledLogTtl, ioc.Resolve<ILogFile>());

            _hubUri = _configRa.MakeHubUri();
            _connector = ioc.Resolve<IAgentConnector>();
            _agents = AgentsRepo.NewSync();
        }
Ejemplo n.º 4
0
 public static ISignalsConfigRa New(SignalsConfig config)
 {
     return
         new SignalsConfigRa(config);
 }
Ejemplo n.º 5
0
 private SignalsConfigRa(SignalsConfig config)
 {
     _config = config;
 }
Ejemplo n.º 6
0
        private static IIoC create_dependencies(SignalsConfig config)
        {
            var ioc = IoC.New();

            var log = LogFile.New(SignalsComponent.LogName);
            var configRa = SignalsConfigRa.New(config);
            var repo = HubRepo.NewSync();
            var idler = Idler.New(log);
            var scheduler = EventScheduler.New(log);

            var throttledLog = ThrottledLog.NewSync(config.ThrottledLogTtl, log);
            var messenger = MessengerEngine.New(throttledLog);

            ioc.Setup()
                .Register(log)
                .Register(configRa)
                .Register(repo)
                .Register(messenger)
                .Register(idler)
                .Register(scheduler);

            var agents = AgentsEngine.New(ioc);

            ioc.Setup()
                .Register(agents);

            return ioc;
        }
Ejemplo n.º 7
0
        private string make_agent_uri(SignalsConfig config)
        {
            var guid = Guid.NewGuid();

            var host = Environment.MachineName;
            var port = config.Port;

            var process = "{0}.{1}".Fmt(
                Process.GetCurrentProcess().ProcessName,
                Process.GetCurrentProcess().Id);

            var uri = config.AgentUri.Substitute(new
                {
                    host, port, process, guid
                });

            return uri;
        }