本文整理汇总了C#中ConnectionConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# ConnectionConfiguration类的具体用法?C# ConnectionConfiguration怎么用?C# ConnectionConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionConfiguration类属于命名空间,在下文中一共展示了ConnectionConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstantiatingAConnectionPoolClient
/**
* This however is still a non-failover connection. Meaning if that `node` goes down the operation will not be retried on any other nodes in the cluster.
*
* To get a failover connection we have to pass an `IConnectionPool` instance instead of a `Uri`.
*/
public void InstantiatingAConnectionPoolClient()
{
var node = new Uri("http://mynode.example.com:8082/apiKey");
var connectionPool = new SniffingConnectionPool(new[] { node });
var config = new ConnectionConfiguration(connectionPool);
var client = new ElasticsearchClient(config);
}
示例2: SetUp
public void SetUp()
{
persistentConnection = MockRepository.GenerateStub<IPersistentConnection>();
channel = MockRepository.GenerateStub<IModel>();
var eventBus = new EventBus();
var configuration = new ConnectionConfiguration();
var shutdownArgs = new ShutdownEventArgs(
ShutdownInitiator.Peer,
AmqpException.ConnectionClosed,
"connection closed by peer");
var exception = new OperationInterruptedException(shutdownArgs);
var first = true;
persistentConnection.Stub(x => x.CreateModel()).WhenCalled(x =>
{
if (first)
{
first = false;
throw exception;
}
x.ReturnValue = channel;
});
var logger = MockRepository.GenerateStub<IEasyNetQLogger>();
persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus);
new Timer(_ => eventBus.Publish(new ConnectionCreatedEvent())).Change(10, Timeout.Infinite);
persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct"));
}
开发者ID:akzhigitov,项目名称:EasyNetQ,代码行数:32,代码来源:When_an_action_is_performed_on_a_closed_channel_that_then_opens.cs
示例3: PersistentConnectionHandler
public PersistentConnectionHandler(AppFunc next, string path, Type connectionType, ConnectionConfiguration configuration)
{
_next = next;
_path = path;
_connectionType = connectionType;
_configuration = configuration;
}
示例4: SetUp
public void SetUp()
{
persistentConnection = MockRepository.GenerateStub<IPersistentConnection>();
var eventBus = MockRepository.GenerateStub<IEventBus>();
var configuration = new ConnectionConfiguration
{
Timeout = 1
};
var shutdownArgs = new ShutdownEventArgs(
ShutdownInitiator.Peer,
AmqpException.ConnectionClosed,
"connection closed by peer");
var exception = new OperationInterruptedException(shutdownArgs);
persistentConnection.Stub(x => x.CreateModel()).WhenCalled(x =>
{
throw exception;
});
var logger = MockRepository.GenerateStub<IEasyNetQLogger>();
persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus);
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:26,代码来源:When_an_action_is_performed_on_a_closed_channel_that_doesnt_open_again.cs
示例5: ProfiledElasticsearchClient
/// <summary>
/// Provides base <see cref="ElasticsearchClient"/> with profiling features to current <see cref="MiniProfiler"/> session.
/// </summary>
/// <param name="configuration">Instance of <see cref="ConnectionConfiguration"/>. Its responses will be handled and pushed to <see cref="MiniProfiler"/></param>
public ProfiledElasticsearchClient(ConnectionConfiguration configuration)
: base(configuration)
{
ProfilerUtils.ExcludeElasticsearchAssemblies();
ProfilerUtils.ApplyConfigurationSettings(configuration);
configuration.SetConnectionStatusHandler(response => MiniProfilerElasticsearch.HandleResponse(response, _profiler));
}
示例6: ConsumerDispatcherFactory
public ConsumerDispatcherFactory(ConnectionConfiguration configuration, IEasyNetQLogger logger)
{
Preconditions.CheckNotNull(configuration, "configuration");
Preconditions.CheckNotNull(logger, "logger");
dispatcher = new Lazy<IConsumerDispatcher>(() => new ConsumerDispatcher(configuration, logger));
}
示例7: Parse
public IConnectionConfiguration Parse(string connectionString)
{
ConnectionString = connectionString;
try
{
connectionConfiguration = new ConnectionConfiguration();
foreach(var pair in
(from property in typeof(ConnectionConfiguration).GetProperties()
let match = Regex.Match(connectionString, string.Format("[^\\w]*{0}=(?<{0}>[^;]+)", property.Name), RegexOptions.IgnoreCase)
where match.Success
select new { Property = property, match.Groups[property.Name].Value }))
pair.Property.SetValue(connectionConfiguration, TypeDescriptor.GetConverter(pair.Property.PropertyType).ConvertFromString(pair.Value),null);
if (ContainsKey("host"))
connectionConfiguration.ParseHosts(this["host"] as string);
connectionConfiguration.Validate();
return connectionConfiguration;
}
catch (Exception parseException)
{
throw new Exception(string.Format("Connection String parsing exception {0}", parseException.Message));
}
}
示例8: IfResponseIsKnowError_DoNotRetry_ThrowServerException_Async
public void IfResponseIsKnowError_DoNotRetry_ThrowServerException_Async(int status, string exceptionType, string exceptionMessage)
{
var response = CreateServerExceptionResponse(status, exceptionType, exceptionMessage);
using (var fake = new AutoFake(callsDoNothing: true))
{
var connectionPool = new StaticConnectionPool(new[]
{
new Uri("http://localhost:9200"),
new Uri("http://localhost:9201"),
});
var connectionConfiguration = new ConnectionConfiguration(connectionPool)
.ThrowOnElasticsearchServerExceptions()
.ExposeRawResponse(false);
fake.Provide<IConnectionConfigurationValues>(connectionConfiguration);
FakeCalls.ProvideDefaultTransport(fake);
var pingCall = FakeCalls.PingAtConnectionLevelAsync(fake);
pingCall.Returns(FakeResponse.OkAsync(connectionConfiguration));
var getCall = FakeCalls.GetCall(fake);
getCall.Returns(FakeResponse.AnyAsync(connectionConfiguration, status, response: response));
var client = fake.Resolve<ElasticsearchClient>();
var e = Assert.Throws<ElasticsearchServerException>(async ()=>await client.InfoAsync());
AssertServerErrorsOnResponse(e, status, exceptionType, exceptionMessage);
//make sure a know ElasticsearchServerException does not cause a retry
//In this case we want to fail early
getCall.MustHaveHappened(Repeated.Exactly.Once);
}
}
示例9: Ping_should_work
public void Ping_should_work()
{
var settings = new ConnectionConfiguration(new Uri(TestConfig.Endpoint));
var client = new ElasticsearchClient(settings, new AwsHttpConnection(settings, TestConfig.AwsSettings));
var response = client.Ping();
Assert.AreEqual(200, response.HttpStatusCode.GetValueOrDefault(-1));
}
示例10: ClientCommandDispatcherFactory
public ClientCommandDispatcherFactory(ConnectionConfiguration configuration, IPersistentChannelFactory persistentChannelFactory)
{
Preconditions.CheckNotNull(configuration, "configuration");
Preconditions.CheckNotNull(persistentChannelFactory, "persistentChannelFactory");
this.configuration = configuration;
this.persistentChannelFactory = persistentChannelFactory;
}
示例11: The_AuthMechanisms_property_should_default_to_PlainMechanism
public void The_AuthMechanisms_property_should_default_to_PlainMechanism()
{
ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration();
connectionConfiguration.AuthMechanisms.Count.ShouldEqual(1);
connectionConfiguration.AuthMechanisms.Single().ShouldBeOfType<PlainMechanismFactory>();
}
示例12: ServerExceptionIsCaught_KeepResponse
public void ServerExceptionIsCaught_KeepResponse(int status, string exceptionType, string exceptionMessage)
{
var response = CreateServerExceptionResponse(status, exceptionType, exceptionMessage);
using (var fake = new AutoFake(callsDoNothing: true))
{
var connectionConfiguration = new ConnectionConfiguration()
.ExposeRawResponse(true);
fake.Provide<IConnectionConfigurationValues>(connectionConfiguration);
FakeCalls.ProvideDefaultTransport(fake);
var getCall = FakeCalls.GetSyncCall(fake);
getCall.Returns(FakeResponse.Bad(connectionConfiguration, response: response));
var client = fake.Resolve<ElasticsearchClient>();
var result = client.Info();
result.Success.Should().BeFalse();
AssertServerErrorsOnResponse(result, status, exceptionType, exceptionMessage);
result.ResponseRaw.Should().NotBeNull();
getCall.MustHaveHappened(Repeated.Exactly.Once);
}
}
示例13: SetUp
public void SetUp()
{
var configuration = new ConnectionConfiguration
{
Hosts = new List<IHostConfiguration>
{
new HostConfiguration { Host = "localhost", Port = 5672 }
},
UserName = "guest",
Password = "guest"
};
configuration.Validate();
var typeNameSerializer = new TypeNameSerializer();
connectionFactory = new ConnectionFactoryWrapper(configuration, new DefaultClusterHostSelectionStrategy<ConnectionFactoryInfo>());
serializer = new JsonSerializer(typeNameSerializer);
conventions = new Conventions(typeNameSerializer);
consumerErrorStrategy = new DefaultConsumerErrorStrategy(
connectionFactory,
serializer,
new ConsoleLogger(),
conventions,
typeNameSerializer);
}
示例14: TestWindow
/// <summary>
/// The test window.
/// </summary>
public void TestWindow()
{
var mocks = new MockRepository();
var mockHttpReq = mocks.Stub<IHttpSonarConnector>();
var mockVsHelpers = mocks.Stub<IVsEnvironmentHelper>();
var config = new ConnectionConfiguration("serveraddr", "login", "password");
// set expectations
using (mocks.Record())
{
SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/issues/search?components=resource"))
.Return(File.ReadAllText("TestData/issuessearchbycomponent.txt"));
SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/users/search")).Return(File.ReadAllText("TestData/userList.txt"));
}
ISonarRestService service = new SonarRestService(mockHttpReq);
service.GetIssuesInResource(config, "resource");
var associatedProject = new Resource { Key = "core:Common" };
this.model = new ExtensionDataModel(service, mockVsHelpers, associatedProject, null);
var t = new Thread(this.Threadprc);
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
}
示例15: ConnectionsWithTheSameConnectionIdLongPollingCloseGracefully
public void ConnectionsWithTheSameConnectionIdLongPollingCloseGracefully()
{
using (var host = new MemoryHost())
{
host.Configure(app =>
{
var config = new ConnectionConfiguration
{
Resolver = new DefaultDependencyResolver()
};
app.MapSignalR<MyGroupEchoConnection>("/echo", config);
config.Resolver.Register(typeof(IProtectedData), () => new EmptyProtectedData());
});
string id = Guid.NewGuid().ToString("d");
var tasks = new List<Task>();
for (int i = 0; i < 1000; i++)
{
tasks.Add(ProcessRequest(host, "longPolling", id));
}
ProcessRequest(host, "longPolling", id);
Task.WaitAll(tasks.ToArray());
Assert.True(tasks.All(t => !t.IsFaulted));
}
}