Exemple #1
0
        public void Initialize(ILighthouseServiceContainer serviceContainer, params Type[] shelvesToUse)
        {
            // only do this once
            if (IsInitialized)
            {
                return;
            }

            // register with the service container
            LighthouseContainer = serviceContainer;

            // Discover shelf types
            foreach (var shelf in DiscoverShelves())
            {
                Shelves.Add(shelf);

                // create all the shelves in the global scope
                shelf.Initialize(this, StorageScope.Global);
            }

            foreach (var shelfType in shelvesToUse)
            {
                if (Activator.CreateInstance(shelfType) is IShelf shelf)
                {
                    Shelves.Add(shelf);

                    // create all the shelves in the global scope
                    shelf.Initialize(this, StorageScope.Global);
                }
            }
        }
Exemple #2
0
 public void Init(ILighthouseServiceContainer container)
 {
     Container  = container;
     Identifier = LighthouseComponentLifetime.GenerateSessionIdentifier(this);
     Container.Log(LogLevel.Debug, LogType.ProducerStartup, this);
     Start();
 }
        public static void AssertEventExists <TEvent>(this ILighthouseServiceContainer container, int count = 1, Func <IEvent, bool> additionalFilter = null, int?atLeast = null)
            where TEvent : IEvent
        {
            //var recCount = container.GetAllReceivedEvents().Where(e => e.GetType() == typeof(TEvent) && (additionalFilter?.Invoke(e) ?? true)).Count();

            //if (atLeast.HasValue)
            //	recCount.Should().BeGreaterOrEqualTo(atLeast.Value);
            //else
            //	recCount.Should().Be(count);
        }
        public WindowsFileSystemProvider(string rootDirectory, ILighthouseServiceContainer container)
        {
            if (string.IsNullOrEmpty(rootDirectory))
            {
                throw new ArgumentException("storageRootDirectory must be specified", nameof(rootDirectory));
            }

            RootDirectory       = rootDirectory;
            LighthouseContainer = container;
            LighthouseContainer.Log(Logging.LogLevel.Info, Logging.LogType.Info, this, $"RootDirectory is {RootDirectory}");
        }
        public Uri ResolveUri(ILighthouseServiceContainer peer)
        {
            foreach (var uriAndPeer in Containers)
            {
                if (uriAndPeer.Value == peer)
                {
                    return(uriAndPeer.Key);
                }
            }

            return(null);
        }
        public void Initialize(ILighthouseServiceContainer container, object context = null)
        {
            if (IsInitialized)
            {
                return;
            }

            // if this has a service moniker us that, otherwise just for got type
            Id = this.ExternalServiceName() ?? GetType().Name;

            Container = container;

            OnInit(context);
        }
        public void Register(ILighthouseServiceContainer node, Dictionary <string, string> otherConfig = null)
        {
            if (!Containers.ContainsValue(node))
            {
                if (otherConfig?.ContainsKey(DesiredUriKey) ?? false)
                {
                    if (Containers.ContainsKey(DesiredUriKey.ToUri()))
                    {
                        throw new ApplicationException("Desired URI is already taken.");
                    }

                    Containers.Add($"http://127.0.0.{highestSubdomain++}".ToUri(), node);
                }
                else
                {
                    // incrememt the URI (these addresses are just automatically assigned, low-rent DHCP)
                    Containers.Add($"http://127.0.0.{highestSubdomain++}".ToUri(), node);
                }
            }
        }
        public IEnumerable <Function> GetFunctions(ILighthouseServiceContainer container, string functionNamespace)
        {
            var functionParser = container.ResolveType <IFunctionParser>();

            if (functionParser == null)
            {
                container.Log(Core.Logging.LogLevel.Debug, Core.Logging.LogType.Error, this, message: "IFunctionParser can't be loaded.");
                throw new ApplicationException("No function parser found.");
            }

            var functions       = new List <Function>();
            var functionStrings = container
                                  .Warehouse?
                                  .Retrieve <IList <string> >(functionNamespace);

            if (functionStrings == null || functionStrings.Count == 0)
            {
                // no functions available
                container.Log(Core.Logging.LogLevel.Debug, Core.Logging.LogType.Info, this, message: "No functions to load");
                return(functions);
            }

            foreach (var functionString in functionStrings)
            {
                if (functionParser.TryParse(functionString, out var function))
                {
                    functions.Add(function);
                }
                else
                {
                    container.Log(
                        Core.Logging.LogLevel.Debug,
                        Core.Logging.LogType.Error,
                        this,
                        message: $"Can't parse function string: {functionString.Substring(0, 100)}"
                        );
                }
            }

            return(functions);
        }
Exemple #9
0
 public MemoryServiceRepository(ILighthouseServiceContainer serviceContainer)
 {
     Container = serviceContainer;
 }
Exemple #10
0
 public void Register(ILighthouseServiceContainer peer, Dictionary <string, string> otherConfig = null)
 {
 }
Exemple #11
0
 public static IEnumerable <T> GetResourceProviders <T>(this ILighthouseServiceContainer container)
     where T : IResourceProvider => container.GetResourceProviders().OfType <T>();
Exemple #12
0
 public static INetworkProvider GetNetworkProvider(this ILighthouseServiceContainer container) => container.GetResourceProviders <INetworkProvider>().FirstOrDefault();
 public void Register(ILighthouseServiceContainer peer, Dictionary <string, string> otherConfig = null)
 {
     // no op, it doesn't care here either
 }
Exemple #14
0
 public BaseEvent(ILighthouseServiceContainer container, DateTime?eventTime = null)
 {
     Container = container;
     EventTime = eventTime ?? container.GetNow();
 }
 public void Register(ILighthouseServiceContainer peer, Dictionary <string, string> otherConfig = null)
 {
     // do nothing?
     // default to C drive I guess?!
 }
 public TestEvent(ILighthouseServiceContainer Container, DateTime?time = null)
 {
     LighthouseContainer = Container;
     EventTime           = time ?? DateTime.Now;
 }
 void IWarehouse.Initialize(ILighthouseServiceContainer container, params Type[] shelvesToUse)
 {
     throw new NotImplementedException("This warehouse server should be initialized within a lighthouse context.");
 }
Exemple #18
0
 /// <summary>
 /// Returns a list of file system providers available on the target server. A given file system could support multiple drives
 /// </summary>
 /// <param name="container"></param>
 /// <returns></returns>
 public static IFileSystemProvider GetFileSystem(this ILighthouseServiceContainer container) => container.GetResourceProviders <IFileSystemProvider>().FirstOrDefault();
 public VirtualLighthouseClient(ILighthouseServiceContainer container, string name)
 {
     Container = container;
     Name      = name;
 }
Exemple #20
0
 public LocalServiceRepository(ILighthouseServiceContainer serviceContainer)
 {
     Container = serviceContainer;
     LoadServices();
 }
Exemple #21
0
 public void Initialize(ILighthouseServiceContainer container, object context = null)
 {
     Container = container;
 }
Exemple #22
0
 public ResourceAvailableEvent(ILighthouseServiceContainer container, IResourceProvider resource)
 {
     LighthouseContainer = container;
     Resource            = resource;
 }
Exemple #23
0
 public RemoteServiceRepository(ILighthouseServiceContainer serviceContainer, string uri)
 {
     URI       = uri;
     Container = serviceContainer;
     RetrieveServiceDescriptors();
 }
 public LogEvent(ILighthouseServiceContainer container, object source)
     : base(container)
 {
     Source = source;
     LighthouseContainer = container;
 }