public GrpcClientAgent(ConsulOptions options) : base(options)
        {
            _options = options;
            var consulSettintOptions = new ConsulSettingOptions()
            {
                ConsulAddressUrl = options.ConsulAddressUrl
            };

            _consulManager = new ConsulManager();
            _consulManager.Init(consulSettintOptions);
        }
        public void GetConfigItem_InvalidKey_NullReturnValue()
        {
            //  Arrange
            string consulServer = "http://localhost:8500/";
            ConfigItem configItem = null;
            string configKey = "testing/bogus";

            //  Act
            ConsulManager client = new ConsulManager(consulServer);
            configItem = client.GetConfigItem(configKey);

            //  Assert
            Assert.IsNull(configItem);
        }
        public void SetConfigItem_ValidKey_ReturnsTrue()
        {
            //  Arrange
            string consulServer = "http://localhost:8500/";
            string configValue = "This is a test";
            string configKey = "testing/testforput";

            //  Act
            ConsulManager client = new ConsulManager(consulServer);
            var wasSuccessful = client.SetConfigItem(configKey, configValue);

            //  Assert
            Assert.IsTrue(wasSuccessful);
        }
        public void SetConfigItem_ValidKey_ReturnsTrue()
        {
            //  Arrange
            string consulServer = "http://localhost:8500/";
            string configValue  = "This is a test";
            string configKey    = "testing/testforput";

            //  Act
            ConsulManager client        = new ConsulManager(consulServer);
            var           wasSuccessful = client.SetConfigItem(configKey, configValue);

            //  Assert
            Assert.IsTrue(wasSuccessful);
        }
        public void GetConfigItem_ValidKey_IsSuccessful()
        {
            //  Arrange
            string consulServer = "http://localhost:8500/";
            ConfigItem configItem = null;
            string configKey = "testing/testconfigitem";

            //  Act
            ConsulManager client = new ConsulManager(consulServer);
            configItem = client.GetConfigItem(configKey);

            //  Assert
            Assert.IsNotNull(configItem);
            Debug.WriteLine("The value for key '{0}' is '{1}' (The raw base64 value is: {2})", configItem.Key, configItem.Value, configItem.Base64Value);
        }
        public void GetConfigItem_InvalidKey_NullReturnValue()
        {
            //  Arrange
            string     consulServer = "http://localhost:8500/";
            ConfigItem configItem   = null;
            string     configKey    = "testing/bogus";

            //  Act
            ConsulManager client = new ConsulManager(consulServer);

            configItem = client.GetConfigItem(configKey);

            //  Assert
            Assert.IsNull(configItem);
        }
        public void GetConfigItem_ValidKey_IsSuccessful()
        {
            //  Arrange
            string     consulServer = "http://localhost:8500/";
            ConfigItem configItem   = null;
            string     configKey    = "testing/testconfigitem";

            //  Act
            ConsulManager client = new ConsulManager(consulServer);

            configItem = client.GetConfigItem(configKey);

            //  Assert
            Assert.IsNotNull(configItem);
            Debug.WriteLine("The value for key '{0}' is '{1}' (The raw base64 value is: {2})", configItem.Key, configItem.Value, configItem.Base64Value);
        }
示例#8
0
        static void Main(string[] args)
        {
            Console.WriteLine(Environment.CurrentDirectory);
            var options = new GrpcServerOptions()
            {
                Host           = "127.0.0.1",
                Port           = 3002,
                NamespaceName  = "Atlantis.Simple",
                PackageName    = "Atlantis.Simple",
                ServiceName    = "AtlantisService",
                ScanAssemblies = new string[]
                {
                    typeof(IPersonServicer).Assembly.FullName
                }
            };

            var consulSetting = new ConsulSettingOptions()
            {
                ConsulAddressUrl = "http://192.168.0.251:8500"
            };
            var serviceOptions = new ConsulServiceOptions()
            {
                ServiceName = "Atlantis.Test",
                Address     = "127.0.0.1",
                Port        = 3002,
                TTL         = 1000
            };

            var consulManager = new ConsulManager()
                                .Init(consulSetting)
                                .WithServiceOptions(serviceOptions);

            consulManager.Service.RegisteAsync().Wait();

            //GrpcConfiguration.LoggerFactory=new Loggerfac();

            var server = new GrpcServer(options);

            ObjectContainer.Register <IPersonServicer, PersonServicer>(LifeScope.Single);
            server.Start();

            Console.WriteLine("Server is running...");
            Console.ReadLine();
        }
 public ChannelManager(ConsulManager consulManager, ILoadBalancer loadBalancer)
 {
     this._consulManager = consulManager;
     this._loadBalancer  = loadBalancer;
 }