Ejemplo n.º 1
0
        public InputModuleWrapper(string inputModuleKey, ModuleDefinition moduleDefinition, YASLServer server)
        {
            Server           = server;
            ModuleKey        = inputModuleKey;
            ModuleDefinition = moduleDefinition;
            Attibutes        = (moduleDefinition.Attributes ?? new Dictionary <string, string>()).Select(x => new Tuple <string, string>(x.Key, x.Value)).ToArray();
            AttributeCount   = Attibutes.Length;
            WorkCompleted    = new ManualResetEvent(false);

            if (!string.IsNullOrWhiteSpace(moduleDefinition.ConfigurationFilePath))
            {
                ConfigurationFilePath = moduleDefinition.ConfigurationFilePath;
                if (File.Exists(ConfigurationFilePath))
                {
                    IsModuleConfigurationFromFile = true;
                    ModuleConfiguration           = JObject.Parse(File.ReadAllText(ConfigurationFilePath));
                }
                else
                {
                    Server.Logger.LogEvent(this, Severity.Error, "InputModuleInit", $"External configuration file not found: {ConfigurationFilePath}.");
                    IsModuleConfigurationFromFile = false;
                    ModuleConfiguration           = moduleDefinition.ConfigurationJSON;
                }
            }
            else
            {
                IsModuleConfigurationFromFile = false;
                ModuleConfiguration           = moduleDefinition.ConfigurationJSON;
            }

            AttachedQueue = Server.QueueFactory.GetMessageQueue(InputModule);
        }
Ejemplo n.º 2
0
        public Filter(string filterKey, FilterDefinition filterDefinition, Dictionary <string, OutputModuleWrapper> outputs, YASLServer server)
        {
            Server        = server;
            FilterKey     = filterKey;
            StopIfMatched = filterDefinition.StopIfMatched;

            FilterExpression = filterDefinition.Expression?.ToObject <Expression>();
            // FilterExpression?.ResolveModules($"{rootPath}\\Expression", cancellationToken, moduleCreators, bindInfo);

            Parser = new Parser(filterDefinition.Parser, outputs, Server);
        }
Ejemplo n.º 3
0
        public Parser(ParserDefinition parserDefinition, Dictionary <string, OutputModuleWrapper> outputs, YASLServer server)
        {
            Server = server;

            List <OutputModuleWrapper> PreOutputs = new List <OutputModuleWrapper>();

            foreach (string outputName in parserDefinition.Output)
            {
                PreOutputs.Add(outputs[outputName]);
            }
            Outputs = PreOutputs.ToArray();
        }
Ejemplo n.º 4
0
        public Route(string routeKey, RouteDefinition routeDefinition, Dictionary <string, OutputModuleWrapper> outputs, YASLServer server)
        {
            Server        = server;
            RouteKey      = routeKey;
            AttachedQueue = Server.QueueFactory.GetMessageQueue(this);
            WorkCompleted = new ManualResetEvent(false);

            foreach (KeyValuePair <string, FilterDefinition> filterCfg in routeDefinition.Filters)
            {
                Filters.Add(filterCfg.Key, new Filter(filterCfg.Key, filterCfg.Value, outputs, server));
            }
            FilterRuntime = Filters.Values.ToArray();
        }
Ejemplo n.º 5
0
        public MessageMixer(Dictionary <string, InputModuleWrapper> inputs, Dictionary <string, Route> routes, Dictionary <string, RouteDefinition> routing, YASLServer server)
        {
            Server        = server;
            WorkCompleted = new ManualResetEvent(false);
            List <Tuple <InputModuleWrapper, Route[]> > PreMixer = new List <Tuple <InputModuleWrapper, Route[]> >();

            foreach (KeyValuePair <string, InputModuleWrapper> input in inputs)
            {
                IEnumerable <string> assignedRouteNames = routing.Where(r => r.Value.Inputs?.Contains(input.Key) == true).Select(n => n.Key);
                if (assignedRouteNames == null || !assignedRouteNames.Any())
                {
                    Server.Logger?.LogEvent(this, Severity.Warning, "MixerInit", $"Input {input.Key} is not used in any route. It will overflow and drop message if sent.");
                }
                else
                {
                    PreMixer.Add(new Tuple <InputModuleWrapper, Route[]>(input.Value, (new List <Route>(routes.Where(r => assignedRouteNames.Contains(r.Key)).Select(p => p.Value))).ToArray()));
                }
            }
            Mixer      = PreMixer.ToArray();
            Forwarders = new MessageDataItem[PreMixer.Max(l => l.Item2.Length)];
        }