コード例 #1
0
        public TrinketProxyEgg()
        {
            streamFactory = new StreamFactory();
             processProxy = new ProcessProxy();
             var pofContext = new PofContext().With(x => {
            x.MergeContext(new DspPofContext());
            x.MergeContext(new TrinketsApiPofContext());
            x.MergeContext(new TrinketsImplPofContext());
             });
             ICollectionFactory collectionFactory = new CollectionFactory();
             IFileSystemProxy fileSystemProxy = new FileSystemProxy(streamFactory);
             IThreadingProxy threadingProxy = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
             var dnsProxy = new DnsProxy();
             INetworkingProxy networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(dnsProxy), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(dnsProxy));
             pofSerializer = new PofSerializer(pofContext);
             PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

             ProxyGenerator proxyGenerator = new ProxyGenerator();
             var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);

             // construct libdsp local service node
             ClusteringConfiguration clusteringConfiguration = new ClientClusteringConfiguration();
             ServiceClient localServiceClient = serviceClientFactory.Construct(clusteringConfiguration);
             keepaliveObjects.Add(localServiceClient);

             temporaryFileService = localServiceClient.GetService<TemporaryFileService>();

             var processInjector = new ProcessInjectorImpl();
             ProcessInjectionConfiguration processInjectionConfiguration = new ProcessInjectionConfigurationImpl(injectionAttempts: 10, injectionAttemptsDelay: 200);
             processInjectionService = new ProcessInjectionServiceImpl(processInjector, processInjectionConfiguration);
             IDtpNodeFactory transportNodeFactory = new DefaultDtpNodeFactory();
             BootstrapConfigurationGenerator bootstrapConfigurationGenerator = new BootstrapConfigurationGeneratorImpl();
             trinketInternalUtilities = new TrinketInternalUtilitiesImpl(fileSystemProxy);
             trinketDtpServerFactory = new TrinketDtpServerFactoryImpl(streamFactory, transportNodeFactory, bootstrapConfigurationGenerator);
        }
コード例 #2
0
        private static void Main(string[] args)
        {
            //var network = new LocalCourierNetwork(dropRate: 0.1);
            IDnsProxy                  dnsProxy                  = new DnsProxy();
            var                        tcpEndPointFactory        = new TcpEndPointFactory(dnsProxy);
            IThreadingFactory          threadingFactory          = new ThreadingFactory();
            ISynchronizationFactory    synchronizationFactory    = new SynchronizationFactory();
            IThreadingProxy            threadingProxy            = new ThreadingProxy(threadingFactory, synchronizationFactory);
            IStreamFactory             streamFactory             = new StreamFactory();
            INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
            ISocketFactory             socketFactory             = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
            INetworkingProxy           networkingProxy           = new NetworkingProxy(socketFactory, tcpEndPointFactory);
            var                        network = new UdpCourierNetwork(networkingProxy, new UdpCourierNetworkConfiguration(50555));
            var                        tasks   = Util.Generate(4, i => new Thread(() => EntryPoint(i, network)).With(t => t.Start()));

            tasks.ForEach(t => t.Join());
        }
コード例 #3
0
        public static int Main()
        {
            ICollectionFactory      collectionFactory            = new CollectionFactory();
            ProxyGenerator          proxyGenerator               = new ProxyGenerator();
            IThreadingFactory       threadingFactory             = new ThreadingFactory();
            ISynchronizationFactory synchronizationFactory       = new SynchronizationFactory();
            IThreadingProxy         threadingProxy               = new ThreadingProxy(threadingFactory, synchronizationFactory);
            IDnsProxy                  dnsProxy                  = new DnsProxy();
            ITcpEndPointFactory        tcpEndPointFactory        = new TcpEndPointFactory(dnsProxy);
            IStreamFactory             streamFactory             = new StreamFactory();
            INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
            ISocketFactory             socketFactory             = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
            INetworkingProxy           networkingProxy           = new NetworkingProxy(socketFactory, tcpEndPointFactory);
            IPofContext                pofContext                = new ClientPofContext();
            IPofSerializer             pofSerializer             = new PofSerializer(pofContext);
            PofStreamsFactory          pofStreamsFactory         = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

            var serviceConfiguration = new ClientClusteringConfiguration();
            var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);
            var localEndPoint        = tcpEndPointFactory.CreateLoopbackEndPoint(serviceConfiguration.Port);
            var reconnectAttempts    = 10;
            var reconnectDelay       = 1000;
            var serviceClient        = TryConnectToEndpoint(reconnectAttempts, reconnectDelay, serviceClientFactory, serviceConfiguration);

            if (serviceClient == null)
            {
                Console.Error.WriteLine("Failed to connect to endpoint.");
                return(1);
            }
            else
            {
                var dispatcher = new DispatcherCommand("registered commands");
                dispatcher.RegisterCommand(new ShutdownCommand(serviceClient));
//            dispatcher.RegisterCommand(new ModCommand(serviceClient));
                dispatcher.RegisterCommand(new ExitCommand());
                dispatcher.RegisterCommand(new ServiceCommand(serviceClient));

                var repl = new DargonREPL(dispatcher);
                repl.Run();
                return(0);
            }
        }
コード例 #4
0
        public TrinketProxyEgg()
        {
            streamFactory = new StreamFactory();
            processProxy  = new ProcessProxy();
            var pofContext = new PofContext().With(x => {
                x.MergeContext(new DspPofContext());
                x.MergeContext(new TrinketsApiPofContext());
                x.MergeContext(new TrinketsImplPofContext());
            });
            ICollectionFactory collectionFactory = new CollectionFactory();
            IFileSystemProxy   fileSystemProxy   = new FileSystemProxy(streamFactory);
            IThreadingProxy    threadingProxy    = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
            var dnsProxy = new DnsProxy();
            INetworkingProxy networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(dnsProxy), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(dnsProxy));

            pofSerializer = new PofSerializer(pofContext);
            PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

            ProxyGenerator proxyGenerator       = new ProxyGenerator();
            var            serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);

            // construct libdsp local service node
            ClusteringConfiguration clusteringConfiguration = new ClientClusteringConfiguration();
            ServiceClient           localServiceClient      = serviceClientFactory.Construct(clusteringConfiguration);

            keepaliveObjects.Add(localServiceClient);

            temporaryFileService = localServiceClient.GetService <TemporaryFileService>();

            var processInjector = new ProcessInjectorImpl();
            ProcessInjectionConfiguration processInjectionConfiguration = new ProcessInjectionConfigurationImpl(injectionAttempts: 10, injectionAttemptsDelay: 200);

            processInjectionService = new ProcessInjectionServiceImpl(processInjector, processInjectionConfiguration);
            IDtpNodeFactory transportNodeFactory = new DefaultDtpNodeFactory();
            BootstrapConfigurationGenerator bootstrapConfigurationGenerator = new BootstrapConfigurationGeneratorImpl();

            trinketInternalUtilities = new TrinketInternalUtilitiesImpl(fileSystemProxy);
            trinketDtpServerFactory  = new TrinketDtpServerFactoryImpl(streamFactory, transportNodeFactory, bootstrapConfigurationGenerator);
        }
コード例 #5
0
        public static int Main()
        {
            ICollectionFactory collectionFactory = new CollectionFactory();
             ProxyGenerator proxyGenerator = new ProxyGenerator();
             IThreadingFactory threadingFactory = new ThreadingFactory();
             ISynchronizationFactory synchronizationFactory = new SynchronizationFactory();
             IThreadingProxy threadingProxy = new ThreadingProxy(threadingFactory, synchronizationFactory);
             IDnsProxy dnsProxy = new DnsProxy();
             ITcpEndPointFactory tcpEndPointFactory = new TcpEndPointFactory(dnsProxy);
             IStreamFactory streamFactory = new StreamFactory();
             INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
             ISocketFactory socketFactory = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
             INetworkingProxy networkingProxy = new NetworkingProxy(socketFactory, tcpEndPointFactory);
             IPofContext pofContext = new ClientPofContext();
             IPofSerializer pofSerializer = new PofSerializer(pofContext);
             PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

             var serviceConfiguration = new ClientClusteringConfiguration();
             var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);
             var localEndPoint = tcpEndPointFactory.CreateLoopbackEndPoint(serviceConfiguration.Port);
             var reconnectAttempts = 10;
             var reconnectDelay = 1000;
             var serviceClient = TryConnectToEndpoint(reconnectAttempts, reconnectDelay, serviceClientFactory, serviceConfiguration);
             if (serviceClient == null) {
            Console.Error.WriteLine("Failed to connect to endpoint.");
            return 1;
             } else {
            var dispatcher = new DispatcherCommand("registered commands");
            dispatcher.RegisterCommand(new ShutdownCommand(serviceClient));
            //            dispatcher.RegisterCommand(new ModCommand(serviceClient));
            dispatcher.RegisterCommand(new ExitCommand());
            dispatcher.RegisterCommand(new ServiceCommand(serviceClient));

            var repl = new DargonREPL(dispatcher);
            repl.Run();
            return 0;
             }
        }
コード例 #6
0
        private ServiceClientFactoryImpl CreateServiceClientFactory(params PofContext[] pofContexts)
        {
            var proxyGenerator = new ProxyGenerator();
            ICollectionFactory      collectionFactory            = new CollectionFactory();
            IThreadingFactory       threadingFactory             = new ThreadingFactory();
            ISynchronizationFactory synchronizationFactory       = new SynchronizationFactory();
            IThreadingProxy         threadingProxy               = new ThreadingProxy(threadingFactory, synchronizationFactory);
            IDnsProxy                  dnsProxy                  = new DnsProxy();
            ITcpEndPointFactory        tcpEndPointFactory        = new TcpEndPointFactory(dnsProxy);
            IStreamFactory             streamFactory             = new StreamFactory();
            INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
            ISocketFactory             socketFactory             = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
            INetworkingProxy           networkingProxy           = new NetworkingProxy(socketFactory, tcpEndPointFactory);
            PofContext                 pofContext                = new DspPofContext();

            pofContexts.ForEach(pofContext.MergeContext);
            IPofSerializer                 pofSerializer                  = new PofSerializer(pofContext);
            PofStreamsFactory              pofStreamsFactory              = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);
            PortableObjectBoxConverter     portableObjectBoxConverter     = new PortableObjectBoxConverter(streamFactory, pofSerializer);
            InvokableServiceContextFactory invokableServiceContextFactory = new InvokableServiceContextFactoryImpl(collectionFactory, portableObjectBoxConverter);

            return(new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory));
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: miyu/Dargon.Platform
        public static void Main(string[] args)
        {
            InitializeLogging();
            // construct libwarty dependencies
            ICollectionFactory collectionFactory = new CollectionFactory();

            // construct libwarty-proxies dependencies
            IStreamFactory          streamFactory                = new StreamFactory();
            IFileSystemProxy        fileSystemProxy              = new FileSystemProxy(streamFactory);
            IThreadingFactory       threadingFactory             = new ThreadingFactory();
            ISynchronizationFactory synchronizationFactory       = new SynchronizationFactory();
            IThreadingProxy         threadingProxy               = new ThreadingProxy(threadingFactory, synchronizationFactory);
            IDnsProxy                  dnsProxy                  = new DnsProxy();
            ITcpEndPointFactory        tcpEndPointFactory        = new TcpEndPointFactory(dnsProxy);
            INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
            ISocketFactory             socketFactory             = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
            INetworkingProxy           networkingProxy           = new NetworkingProxy(socketFactory, tcpEndPointFactory);
            IProcessProxy              processProxy              = new ProcessProxy();

            // construct Castle.Core dependencies
            ProxyGenerator proxyGenerator = new ProxyGenerator();

            // construct Platform Root Portable Object Format dependencies
            IPofContext    pofContext    = new PlatformPofContext();
            IPofSerializer pofSerializer = new PofSerializer(pofContext);

            // construct libdargon.management dependencies
            var                            managementServerEndpoint      = tcpEndPointFactory.CreateAnyEndPoint(kPlatformManagementPort);
            IMessageFactory                managementMessageFactory      = new MessageFactory();
            IManagementSessionFactory      managementSessionFactory      = new ManagementSessionFactory(collectionFactory, threadingProxy, pofSerializer, managementMessageFactory);
            ILocalManagementServerContext  managementServerContext       = new LocalManagementServerContext(collectionFactory, managementSessionFactory);
            IManagementContextFactory      managementContextFactory      = new ManagementContextFactory(pofContext);
            ILocalManagementRegistry       localManagementServerRegistry = new LocalManagementRegistry(pofSerializer, managementContextFactory, managementServerContext);
            IManagementServerConfiguration managementServerConfiguration = new ManagementServerConfiguration(managementServerEndpoint);
            var                            server = new LocalManagementServer(threadingProxy, networkingProxy, managementSessionFactory, managementServerContext, managementServerConfiguration);

            server.Initialize();

            // construct system-state dependencies
            ICache <string, string> systemStateCache = new InMemoryCache <string, string>("SystemState", new ICacheIndex[0]);
            var platformSystemState = new PlatformSystemStateImpl(systemStateCache);

            localManagementServerRegistry.RegisterInstance(new PlatformSystemStateMob(platformSystemState));

            // construct platform foundational dependencies
            ICacheFactory        cacheFactory         = new CacheFactory();
            PlatformCacheService platformCacheService = new PlatformCacheServiceImpl(collectionFactory, cacheFactory).With(x => x.Initialize());
            Caches specializedCaches = new Caches(platformCacheService);
            SpecializedCacheService specializedCacheService = new SpecializedCacheServiceImpl(specializedCaches);

            // construct backend account service dependencies
            ICache <string, long>             emailToAccountIdCache = new InMemoryCache <string, long>(Accounts.Hydar.CacheNames.kEmailToAccountIdCache, new ICacheIndex[0]);
            ICache <long, AccountInformation> accountInfoByIdCache  = new InMemoryCache <long, AccountInformation>(Accounts.Hydar.CacheNames.kAccountInfoByIdCache, new ICacheIndex[0]);
            IDistributedCounter accountIdCounter  = specializedCacheService.GetCountingCache(Accounts.Hydar.CacheNames.kAccountIdCountingCacheName);
            IPasswordUtilities  passwordUtilities = new PasswordUtilities();
            AccountCache        accountCache      = new AccountCache(emailToAccountIdCache, accountInfoByIdCache, accountIdCounter, passwordUtilities);
            var accountService = new AccountServiceImpl(accountCache);

            localManagementServerRegistry.RegisterInstance(new AccountCacheMob(accountCache));

            // construct frontend identity service dependencies
            ICache <string, Identity>           identityByTokenHydarCache          = new InMemoryCache <string, Identity>(Draek.Identities.Hydar.CacheNames.kIdentityByTokenCache, new ICacheIndex[0]);
            AuthenticationTokenFactory          authenticationTokenFactory         = new AuthenticationTokenFactoryImpl();
            IdentityByTokenCache                identityByTokenCache               = new IdentityByTokenCacheImpl(identityByTokenHydarCache);
            IAuthenticationServiceConfiguration authenticationServiceConfiguration = new AuthenticationServiceConfiguration(platformSystemState);
            AuthenticationService               authenticationService              = new AuthenticationServiceImpl(accountService, authenticationTokenFactory, identityByTokenCache, authenticationServiceConfiguration);
            var identityService = new IdentityServiceProxyImpl(authenticationService);

            localManagementServerRegistry.RegisterInstance(new AuthenticationServiceMob(authenticationService));
            localManagementServerRegistry.RegisterInstance(new IdentityCacheMob(identityByTokenCache));
            localManagementServerRegistry.RegisterInstance(new AuthenticationServiceConfigurationMob(authenticationServiceConfiguration));

            Application.Run();
        }