Skip to content

Commit

Permalink
Clarify Cluster and ClusterHelper classes dotnet
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrymorris authored and ingenthr committed Jun 21, 2016
1 parent 41b0219 commit 7e50825
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions content/sdk/dotnet/managing-connections.dita
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@
practices as well as information on the connection string, SSL and other advanced connection options.</shortdesc>
<conbody>
<section>
<title>Connecting to a Bucket</title>
<p>Connecting to a bucket is a two-step process: first, a <codeph>CouchbaseCluster</codeph>
object needs to be created or the <apiname>ClusterHelper</apiname> object needs to be initialized, followed by
one or more calls to <apiname>OpenBucket()</apiname> or <apiname>GetBucket(..)</apiname>:</p>
<title>Connecting to a Cluster and Opening a Bucket</title>
<p>Connecting to a bucket is a two-step process: first, a <b><codeph>Cluster</codeph></b>
object needs to be created or the <b><apiname>ClusterHelper</apiname></b> object needs to be
initialized, followed by one or more calls to <apiname>OpenBucket()</apiname> or
<apiname>GetBucket(..)</apiname>:</p>
<codeblock outputclass="language-csharp"><![CDATA[var cluster = Cluster();
var bucket = cluster.OpenBucket("default");
//or alternately
ClusterHelper.Initialize();
var bucket = ClusterHelper.GetBucket("default);]]></codeblock>
<p>If no further arguments are applied, this code connects to <codeph>localhost</codeph> and
opens the <i>default</i> bucket. While this is suitable for development, you most probably
want to connect to a remote cluster and also a different bucket (with a password), to do
this you create a <apiname>ClientConfiguration</apiname> object can be constructed with a custom
configuration:</p>
<p><note>The <apiname>ClusterHelper</apiname> is a singleton/multiton that makes it easier to manage resources
and instances in server runtime environments such as ASP.NET and Owin/Katana. A
<apiname>ClusterHelper</apiname> will make a singleton instance of a <apiname>Cluster</apiname> object and configuration and
store references to opened <apiname>IBucket</apiname> objects that can be reused throughout the lifespan of
an application.</note>If no further arguments are applied, this code connects to
<codeph>localhost</codeph> and opens the <i>default</i> bucket. While this is suitable for
development, you most probably want to connect to a remote cluster and also a different
bucket (with a password), to do this you create a <apiname>ClientConfiguration</apiname>
object can be constructed with a custom configuration:</p>
<codeblock outputclass="language-csharp"><![CDATA[//define a configuration object
var config = new ClientConfiguration {
Servers = new List<Uri> {
Expand Down

0 comments on commit 7e50825

Please sign in to comment.