示例#1
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder();

            builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
            var configuration = builder.Build();

            var gateways = configuration.GetSection("GatewayAddress").Get <NetAddress[]>();

            ServiceCollection services = new ServiceCollection();

            services.AddSingleton <IConfiguration>(configuration);
            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.AddConfiguration(configuration.GetSection("Logging"));
                loggingBuilder.AddConsole(); // 将日志输出到控制台
            });

            var msp = new MicroServiceHost(services);

            //注册支持的服务类型
            msp.Register <UserInfoController>("UserInfo");
            msp.Build(7901, gateways)
            .Run();
        }
示例#2
0
 public FaildCommitBuilder(MicroServiceHost microServiceHost,
                           RetryCommitMission retryCommitMission,
                           ILogger <TransactionDelegate> loggerTran)
 {
     this._retryCommitMission = retryCommitMission;
     this._loggerTran         = loggerTran;
     this._microServiceHost   = microServiceHost;
 }
示例#3
0
 public InvokeRequestHandler(TransactionDelegateCenter transactionDelegateCenter,
                             ILogger <InvokeRequestHandler> logger,
                             MicroServiceHost microServiceProvider)
 {
     _transactionDelegateCenter = transactionDelegateCenter;
     _MicroServiceProvider      = microServiceProvider;
     _logger = logger;
 }
示例#4
0
        public void Test()
        {
            MicroServiceHost host = new MicroServiceHost(new ServiceCollection());

            host.Register <TestController>("testService");
            var type    = typeof(MicroServiceHost).Assembly.GetType("JMS.GenerateCode.CodeBuilder");
            var builder = Activator.CreateInstance(type, new object[] { host });
            var str     = type.GetMethod("GenerateCode").Invoke(builder, new object[] { "abc", "MyClass", "testService" });
        }
示例#5
0
 public GatewayConnector(MicroServiceHost microServiceHost,
                         ICpuInfo cpuInfo,
                         SSLConfiguration sSLConfiguration,
                         ILogger <GatewayConnector> logger, IKeyLocker keyLocker)
 {
     _microServiceHost = microServiceHost;
     _logger           = logger;
     _keyLocker        = keyLocker;
     _cpuInfo          = cpuInfo;
     _SSLConfiguration = sSLConfiguration;
 }
示例#6
0
 public InvokeRequestHandler(TransactionDelegateCenter transactionDelegateCenter,
                             ILogger <InvokeRequestHandler> logger,
                             ILogger <TransactionDelegate> loggerTran,
                             MicroServiceHost microServiceProvider,
                             FaildCommitBuilder faildCommitBuilder)
 {
     this._faildCommitBuilder   = faildCommitBuilder;
     _transactionDelegateCenter = transactionDelegateCenter;
     _MicroServiceProvider      = microServiceProvider;
     _logger     = logger;
     _loggerTran = loggerTran;
 }
示例#7
0
        public static void Main(string[] args)
        {
            /**
             *  TODO: Running on default hosting address here, need to make sure
             *  where we would want to host DataCat. Having a setting would be
             *  definitely nice here.
             * */

            var host = MicroServiceHost.CreateHost <Startup>("DataCat", "http://*:5000", args);

            host.Run();
        }
示例#8
0
        public RequestReception(ILogger <RequestReception> logger,
                                ProcessExitHandler processExitHandler,
                                MicroServiceHost microServiceProvider)
        {
            _logger = logger;
            _MicroServiceProvider = microServiceProvider;
            _processExitHandler   = processExitHandler;
            _SSLConfiguration     = _MicroServiceProvider.ServiceProvider.GetService <SSLConfiguration>();

            var handlerTypes = typeof(RequestReception).Assembly.DefinedTypes.Where(m => m.ImplementedInterfaces.Contains(typeof(IRequestHandler)));

            foreach (var type in handlerTypes)
            {
                var handler = (IRequestHandler)microServiceProvider.ServiceProvider.GetService(type);
                _cache[handler.MatchType] = handler;
            }
        }
示例#9
0
 public static void Main(string[] args)
 {
     MicroServiceHost.Start(args);
 }
示例#10
0
 public RetryCommitMission(MicroServiceHost microServiceHost, ILogger <TransactionDelegate> loggerTran)
 {
     this._microServiceHost = microServiceHost;
     this._loggerTran       = loggerTran;
 }
示例#11
0
 public CodeBuilder(MicroServiceHost microServiceProvider)
 {
     _microServiceProvider = microServiceProvider;
 }
示例#12
0
 public MapFileManager(MicroServiceHost microServiceHost)
 {
     _microServiceHost = microServiceHost;
 }
示例#13
0
 public KeyLocker(MicroServiceHost microServiceHost)
 {
     _microServiceHost  = microServiceHost;
     this.LockedKeyDict = new ConcurrentDictionary <string, string>();
     RemovingKeyDict    = new ConcurrentDictionary <string, string>();
 }
示例#14
0
 public static IMicroServiceHost BuildMicroServiceHost(string[] args) =>
 MicroServiceHost.CreateDefaultBuilder(args)
 .UseStartup <MicroServiceStartup>()
 .Build();