当前位置: 首页>>代码示例>>C#>>正文


C# ConnectionSettings类代码示例

本文整理汇总了C#中ConnectionSettings的典型用法代码示例。如果您正苦于以下问题:C# ConnectionSettings类的具体用法?C# ConnectionSettings怎么用?C# ConnectionSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConnectionSettings类属于命名空间,在下文中一共展示了ConnectionSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WhenPostExceedsHttpLimit_DoNotRetry_UsingConnectionPooling

		public void WhenPostExceedsHttpLimit_DoNotRetry_UsingConnectionPooling()
		{
			var pool = new StaticConnectionPool(new []
			{
				new Uri("http://localhost:9200"),
				new Uri("http://127.0.0.1:9200"),
			});
			var settings = new ConnectionSettings(pool);
			var client = new ElasticClient(settings);


			var index = ElasticsearchConfiguration.NewUniqueIndexName();
			var projects = NestTestData.Data;
			var people = NestTestData.People;
			var boolTerms = NestTestData.BoolTerms;
			var bulk = client.Bulk(b => b
				.FixedPath(index)
				.IndexMany(projects)
				.IndexMany(people)
				.IndexMany(boolTerms)
			);

			bulk.IsValid.Should().BeFalse();
			bulk.ConnectionStatus.NumberOfRetries.Should().Be(0);
		}
开发者ID:radiosterne,项目名称:elasticsearch-net,代码行数:25,代码来源:Reproduce945Tests.cs

示例2: EventStoreConnectionLogicHandler

        public EventStoreConnectionLogicHandler(IEventStoreConnection esConnection, ConnectionSettings settings)
        {
            Ensure.NotNull(esConnection, "esConnection");
            Ensure.NotNull(settings, "settings");

            _esConnection = esConnection;
            _settings = settings;

            _operations = new OperationsManager(_esConnection.ConnectionName, settings);
            _subscriptions = new SubscriptionsManager(_esConnection.ConnectionName, settings);

            _queue.RegisterHandler<StartConnectionMessage>(msg => StartConnection(msg.Task, msg.EndPointDiscoverer));
            _queue.RegisterHandler<CloseConnectionMessage>(msg => CloseConnection(msg.Reason, msg.Exception));

            _queue.RegisterHandler<StartOperationMessage>(msg => StartOperation(msg.Operation, msg.MaxRetries, msg.Timeout));
            _queue.RegisterHandler<StartSubscriptionMessage>(StartSubscription);

            _queue.RegisterHandler<EstablishTcpConnectionMessage>(msg => EstablishTcpConnection(msg.EndPoints));
            _queue.RegisterHandler<TcpConnectionEstablishedMessage>(msg => TcpConnectionEstablished(msg.Connection));
            _queue.RegisterHandler<TcpConnectionErrorMessage>(msg => TcpConnectionError(msg.Connection, msg.Exception));
            _queue.RegisterHandler<TcpConnectionClosedMessage>(msg => TcpConnectionClosed(msg.Connection));
            _queue.RegisterHandler<HandleTcpPackageMessage>(msg => HandleTcpPackage(msg.Connection, msg.Package));

            _queue.RegisterHandler<TimerTickMessage>(msg => TimerTick());

            _timer = new Timer(_ => EnqueueMessage(TimerTickMessage), null, Consts.TimerPeriod, Consts.TimerPeriod);
        }
开发者ID:thinkbeforecoding,项目名称:EventStore,代码行数:27,代码来源:EventStoreConnectionLogicHandler.cs

示例3: ShouldFailoverOnThriftConnectionsUsingSniff

		public void ShouldFailoverOnThriftConnectionsUsingSniff()
		{
			var uris = new []
			{
				new Uri("http://INVALID_HOST"),
				new Uri("http://INVALID_HOST2"),
				new Uri("http://localhost:9500"),
			};
			var connectionPool = new SniffingConnectionPool(uris, randomizeOnStartup: false);
			var settings = new ConnectionSettings(connectionPool, ElasticsearchConfiguration.DefaultIndex)
				.SniffOnStartup()
				.ExposeRawResponse()
				.SetTimeout(2000);
			var client = new ElasticClient(settings, new ThriftConnection(settings));

			var results = client.Search<dynamic>(s => s.MatchAll());
			results.IsValid.Should().BeTrue("{0}", results.ConnectionStatus.ToString());
			results.ConnectionStatus.NumberOfRetries.Should().Be(0);
			var u = new Uri(results.ConnectionStatus.RequestUrl);
			u.Port.Should().Be(9500);

			results = client.Search<dynamic>(s => s.MatchAll());
			results.IsValid.Should().BeTrue("{0}", results.ConnectionStatus.ToString());
			results.ConnectionStatus.NumberOfRetries.Should().Be(0);
			u = new Uri(results.ConnectionStatus.RequestUrl);
			u.Port.Should().Be(9501);
		}
开发者ID:strongant,项目名称:elasticsearch-net,代码行数:27,代码来源:ThiftBugReportTests.cs

示例4: EventStoreEmbeddedNodeConnection

        public EventStoreEmbeddedNodeConnection(ConnectionSettings settings, string connectionName, IPublisher publisher, ISubscriber bus, IAuthenticationProvider authenticationProvider)
        {
            Ensure.NotNull(publisher, "publisher");
            Ensure.NotNull(settings, "settings");

            Guid connectionId = Guid.NewGuid();

            _settings = settings;
            _connectionName = connectionName;
            _publisher = publisher;
            _authenticationProvider = authenticationProvider;
            _subscriptionBus = new InMemoryBus("Embedded Client Subscriptions");
            _subscriptions = new EmbeddedSubscriber(_subscriptionBus, _authenticationProvider, _settings.Log, connectionId);
            
            _subscriptionBus.Subscribe<ClientMessage.SubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.SubscriptionDropped>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.StreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.PersistentSubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.PersistentSubscriptionStreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.SubscribeToStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.UnsubscribeFromStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.ConnectToPersistentSubscription>(_publisher.Publish));

            bus.Subscribe(new AdHocHandler<SystemMessage.BecomeShutdown>(_ => Disconnected(this, new ClientConnectionEventArgs(this, new IPEndPoint(IPAddress.None, 0)))));
        }
开发者ID:danieldeb,项目名称:EventStore,代码行数:25,代码来源:EventStoreEmbeddedNodeConnection.cs

示例5: SniffOnStartShouldOnlyHit9200_WithoutPing_Async

		public async void SniffOnStartShouldOnlyHit9200_WithoutPing_Async()
		{
			var seeds = new[]
			{
				ElasticsearchConfiguration.CreateBaseUri(9202),
				ElasticsearchConfiguration.CreateBaseUri(9201),
				ElasticsearchConfiguration.CreateBaseUri(9200)
			};
			var sniffingConnectionPool = new SniffingConnectionPool(seeds, randomizeOnStartup: false);
			var connectionSettings = new ConnectionSettings(sniffingConnectionPool)
				.SniffOnStartup();
			var client = new ElasticClient(connectionSettings);
			var rootNode = await client.RootNodeInfoAsync();
			var metrics = rootNode.ConnectionStatus.Metrics;
			
			//When the connectionpool is used for the first time the sniff call should already
			//know only 9200 is on and live, no need to ping
			metrics.Requests.Count.Should().Be(1);
			metrics.Requests[0].Node.Port.Should().Be(9200);
			metrics.Requests[0].RequestType.Should().Be(RequestType.ElasticsearchCall);

			for (var i = 0; i < 3; i++)
			{
				rootNode = await client.RootNodeInfoAsync();
				metrics = rootNode.ConnectionStatus.Metrics;
				metrics.Requests.Count.Should().Be(1);
				metrics.Requests[0].Node.Port.Should().Be(9200);
				metrics.Requests[0].RequestType.Should().Be(RequestType.ElasticsearchCall);
			}

		}
开发者ID:BiYiTuan,项目名称:elasticsearch-net,代码行数:31,代码来源:FailoverSniffOnStartupTests.cs

示例6: SubscriptionsManager

 public SubscriptionsManager(string connectionName, ConnectionSettings settings)
 {
     Ensure.NotNull(connectionName, "connectionName");
     Ensure.NotNull(settings, "settings");
     _connectionName = connectionName;
     _settings = settings;
 }
开发者ID:adbrowne,项目名称:EventStore,代码行数:7,代码来源:SubscriptionsManager.cs

示例7: MailBeeEmailClient

		public MailBeeEmailClient(ConnectionSettings settings)
		{
			_settings = settings;
			_client = settings.GetEmailProtocol() == EmailProtocol.Imap
				? (IMailBeeClient) new ImapMailBeeClient()
				: new Pop3MailBeeClient();
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:7,代码来源:MailBeeEmailClient.cs

示例8: ElasticsearchRepositoryDocumentNotExistsSpecs

        public ElasticsearchRepositoryDocumentNotExistsSpecs()
        {
            var settings = new ConnectionSettings();

            _client = new ElasticClient(settings, new InMemoryConnection(settings, string.Empty, 404));
            _repository = new ElasticsearchRepository(_client);
        }
开发者ID:Philo,项目名称:Nest-Queryify,代码行数:7,代码来源:ElasticsearchRepositoryDocumentNotExistsSpecs.cs

示例9: TestIndexTimeout

        public void TestIndexTimeout()
        {
            var timeout = 1;
            var s = new ConnectionSettings(Test.Default.Host, Test.Default.Port, timeout)
                        .SetDefaultIndex(Test.Default.DefaultIndex)
                        .SetMaximumAsyncConnections(Test.Default.MaximumAsyncConnections)
                        .UsePrettyResponses();

            var client = new ElasticClient(s);

            var newProject = new ElasticSearchProject
            {
                Name = "COBOLES", //COBOL ES client ?
            };
            var t = client.IndexAsync<ElasticSearchProject>(newProject);
            t.Wait(1000);
              var r = t.Result;
              Assert.True(r.IsValid);
              Assert.IsNotNullOrEmpty(r.Id);

            var cs = r.ConnectionStatus;
            Assert.False(cs.Success);
            Assert.NotNull(cs.Error);
            Assert.NotNull(cs.Error.OriginalException);
            Trace.WriteLine(cs.Error.OriginalException);
            Assert.IsNotNullOrEmpty(cs.Error.ExceptionMessage);
            Assert.IsTrue(cs.Error.OriginalException is WebException);
            var we = cs.Error.OriginalException as WebException;
            Assert.IsTrue(cs.Error.ExceptionMessage.Contains("The request was canceled"));
            Assert.IsTrue(we.Status == WebExceptionStatus.RequestCanceled);
            Assert.True(t.IsCompleted, "task did not complete");
            Assert.False(t.IsFaulted, "task was faulted, wich means the exception did not cleanly pass to ConnectionStatus");
        }
开发者ID:Moran007,项目名称:NEST,代码行数:33,代码来源:AsyncTests.cs

示例10: FailoverShouldOnlyPingDeadNodes

		public void FailoverShouldOnlyPingDeadNodes()
		{
			var seeds = new[]
			{
				ElasticsearchConfiguration.CreateBaseUri(9202),
				ElasticsearchConfiguration.CreateBaseUri(9201),
				ElasticsearchConfiguration.CreateBaseUri(9200)
			};
			var sniffingConnectionPool = new SniffingConnectionPool(seeds, randomizeOnStartup: false);
			var connectionSettings = new ConnectionSettings(sniffingConnectionPool);
			var client = new ElasticClient(connectionSettings);
			var rootNode = client.RootNodeInfo();
			var metrics = rootNode.ConnectionStatus.Metrics;
			
			//ping 9202 + 9201 + 9200 and call 9200
			metrics.Requests.Count.Should().Be(4);
			metrics.Requests[0].Node.Port.Should().Be(9202);
			metrics.Requests[0].RequestType.Should().Be(RequestType.Ping);
			metrics.Requests[0].EllapsedMilliseconds.Should().BeLessOrEqualTo(1100);
			metrics.Requests[1].Node.Port.Should().Be(9201);
			metrics.Requests[1].RequestType.Should().Be(RequestType.Ping);
			metrics.Requests[1].EllapsedMilliseconds.Should().BeLessOrEqualTo(1100);
			metrics.Requests[2].Node.Port.Should().Be(9200);
			metrics.Requests[2].RequestType.Should().Be(RequestType.Ping);
			metrics.Requests[2].EllapsedMilliseconds.Should().BeLessOrEqualTo(1100);
			metrics.Requests[3].Node.Port.Should().Be(9200);
			metrics.Requests[3].RequestType.Should().Be(RequestType.ElasticsearchCall);
			metrics.Requests[3].EllapsedMilliseconds.Should().BeLessOrEqualTo(1100);



			rootNode = client.RootNodeInfo();
			metrics = rootNode.ConnectionStatus.Metrics;
			metrics.Requests.Count.Should().Be(1);
			metrics.Requests[0].Node.Port.Should().Be(9200);
			metrics.Requests[0].RequestType.Should().Be(RequestType.ElasticsearchCall);

			rootNode = client.RootNodeInfo();
			metrics = rootNode.ConnectionStatus.Metrics;
			metrics.Requests.Count.Should().Be(1);
			metrics.Requests[0].Node.Port.Should().Be(9200);
			metrics.Requests[0].RequestType.Should().Be(RequestType.ElasticsearchCall);


			rootNode = client.RootNodeInfo();
			metrics = rootNode.ConnectionStatus.Metrics;
			metrics.Requests.Count.Should().Be(1);
			metrics.Requests[0].Node.Port.Should().Be(9200);
			metrics.Requests[0].RequestType.Should().Be(RequestType.ElasticsearchCall);


			rootNode = client.RootNodeInfo();	
			metrics = rootNode.ConnectionStatus.Metrics;
			metrics.Requests.Count.Should().Be(1);
			metrics.Requests[0].Node.Port.Should().Be(9200);
			metrics.Requests[0].RequestType.Should().Be(RequestType.ElasticsearchCall);


		}
开发者ID:strongant,项目名称:elasticsearch-net,代码行数:59,代码来源:FailoverPingTests.cs

示例11: Construct_Client_With_Invalid_Hostname

		public void Construct_Client_With_Invalid_Hostname()
		{
			Assert.Throws<UriFormatException>(() =>
			{
				var settings = new ConnectionSettings(new Uri("some mangled hostname:80"), "index");
			});

		}
开发者ID:JebteK,项目名称:elasticsearch-net,代码行数:8,代码来源:ConnectionTests.cs

示例12: Exchange

        private Exchange(ConnectionSettings connectionSettings, string name, string type, bool durable)
            : base(connectionSettings, name)
        {
            this.Type = type;
            this.Durable = durable;

            this.Channel.ExchangeDeclare(this.Name, this.Type, durable);
        }
开发者ID:ZhangColin,项目名称:IDDD_Samples_by_Colin,代码行数:8,代码来源:Exchange.cs

示例13: DeserializeOfStreamDoesNotHoldACopyOfTheResponse

        public void DeserializeOfStreamDoesNotHoldACopyOfTheResponse()
        {
            var uri = ElasticsearchConfiguration.CreateBaseUri();
            var settings = new ConnectionSettings(uri, ElasticsearchConfiguration.DefaultIndex);
            IElasticClient client = new ElasticClient(settings);

            var results = client.Search<ElasticsearchProject>(s => s.MatchAll());
        }
开发者ID:NickCraver,项目名称:NEST,代码行数:8,代码来源:MemoryUsageTests.cs

示例14: OrganizationRequestBuilderVisitor

 public OrganizationRequestBuilderVisitor(ICrmMetaDataProvider crmMetadataProvider, DbParameterCollection parameters, IDynamicsAttributeTypeProvider typeProvider, ConnectionSettings settings = null)
 {
     CrmMetadataProvider = crmMetadataProvider;
     Parameters = parameters;
     TypeProvider = typeProvider;
     Settings = settings ?? ConnectionSettings.Default();
     // OrgCommand = new OrganisationRequestCommand();
 }
开发者ID:YOTOV-LIMITED,项目名称:CrmAdo,代码行数:8,代码来源:OrganizationRequestBuilderVisitor.cs

示例15: CheckConnection

		private static void CheckConnection(ConnectionSettings settings, PluginProfileErrorCollection errors)
		{
			using (IEmailClient client = new MailBeePop3EmailClient(settings))
			{
				client.CheckConnection(errors);
				client.Disconnect();
			}
		}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:8,代码来源:CheckConnectionCommand.cs


注:本文中的ConnectionSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。