We’ve only just now come around to doing an upgrade from the (rather old) version of Couchbase we are on to the latest, for a variety of reasons. Unfortunately, we are currently using v1.1.6 of the Couchbase Client SDK for .NET. Moving to v2.3.4 seems to bring a lot of breaking changes, currently all centred around configuration.
We used to use the old CouchbaseClientConfiguration
type, which seems to be been superseded now with ClientConfiguration
(also with BucketConfiguration
and PoolConfiguration
). I’ve managed to migrate most of the configuration itself, but what is unclear now is the timeouts.
An example of how it used to hook up:
var clientConfiguration = new CouchbaseClientConfiguration()
{
Bucket = MembaseBucketName,
BucketPassword = MembaseBucketPassword
};
// <servers retryCount="3" retryTimeout="00:00:30" >
// <add uri="" />
// <add uri="" />
// </servers>
foreach (string host in root.Elements("servers").Elements("add").Attributes("uri"))
{
clientConfiguration.Servers.Add(new Uri(host));
}
// <servers retryCount="3" retryTimeout="00:00:30" >
clientConfiguration.RetryTimeout = TimeSpan.Parse(root.Element("servers").Attribute("retryTimeout").Value);
clientConfiguration.RetryCount = Convert.ToInt32(root.Element("servers").Attribute("retryCount").Value);
// <socketPool minPoolSize="10" maxPoolSize="10" connectionTimeout="00:00:30" deadTimeout="00:00:30" queueTimeout="00:00:30" receiveTimeout="00:00:30" />
clientConfiguration.SocketPool.MinPoolSize =
Convert.ToInt32(root.Element("socketPool").Attribute("minPoolSize").Value);
clientConfiguration.SocketPool.MaxPoolSize =
Convert.ToInt32(root.Element("socketPool").Attribute("maxPoolSize").Value);
clientConfiguration.SocketPool.ConnectionTimeout =
TimeSpan.Parse(root.Element("socketPool").Attribute("connectionTimeout").Value);
clientConfiguration.SocketPool.DeadTimeout =
TimeSpan.Parse(root.Element("socketPool").Attribute("deadTimeout").Value);
clientConfiguration.SocketPool.QueueTimeout =
TimeSpan.Parse(root.Element("socketPool").Attribute("queueTimeout").Value);
clientConfiguration.SocketPool.ReceiveTimeout =
TimeSpan.Parse(root.Element("socketPool").Attribute("receiveTimeout").Value);
And this is what I’ve managed to translate so far:
var clientConfiguration = new ClientConfiguration
{
BucketConfigs = new Dictionary<string, BucketConfiguration>
{
{
MembaseBucketName,
new BucketConfiguration
{
BucketName = MembaseBucketName,
Password = MembaseBucketPassword,
// <servers retryCount="3" retryTimeout="00:00:30" >
// <add uri="" />
// <add uri="" />
// </servers>
Servers = root.Elements("servers").Elements("add").Attributes("uri").ToList(_ => new Uri(_.Value)),
PoolConfiguration = new PoolConfiguration
{
MinSize = Convert.ToInt32(root.Element("socketPool").Attribute("minPoolSize").Value),
MaxSize = Convert.ToInt32(root.Element("socketPool").Attribute("maxPoolSize").Value),
ConnectTimeout = (int)TimeSpan.Parse(root.Element("socketPool").Attribute("connectionTimeout").Value).TotalMilliseconds,
WaitTimeout = (int)TimeSpan.Parse(root.Element("socketPool").Attribute("queueTimeout").Value).TotalMilliseconds,
},
DefaultOperationLifespan = (uint)TimeSpan.Parse(root.Element("socketPool").Attribute("receiveTimeout").Value).TotalMilliseconds,
}
},
},
};
We used to specify: QueueTimeout
, DeadTimeout
, ReceiveTimeout
, ConnectionTimeout
, RetryTimeout
and RetryCount
. There are some likely candidates for where these migrate to, but I thought I’d play it safe and get the answer direct.
I also have a minor question around where Servers
and PoolConfiguration
lives, because it is available on both ClientConfiguration
and BucketConfiguration
. We only run one bucket, with a few server URIs, so the total config is not complicated.
Any pointers or any documentation on this would be appreciated. What I’m struggling with is what the timeouts used to do and what the equivalent is now, or if any of the concepts changed on the way through the versions.
Thanks.