Skip to content

Commit

Permalink
Installation and Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
moesaleh committed Oct 8, 2014
1 parent 3245104 commit 70bfb03
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,86 @@ OrleansCouchbaseStorageProvider
===============================

An Orleans grain state provider which persists state in JSON format in Couchbase Database Storage

The `master` branch targets the September (0.9) Orleans SDK release and Couchbase .NET Client Library 1.2.5

## Installation

The Orleans SDK must be installed first.

Using NuGet, with the GrainClasses implementation (or Silo Host) project as your target:

```
Install-Package Orleans.StorageProvider.Blob
```
Then install Couchbase .NET Client Library 1.2.5 using NuGet:

```
Install-Package CouchbaseNetClient
```

Then register the provider in your Silo Configuration:

```xml
<?xml version="1.0" encoding="utf-8"?>
<OrleansConfiguration xmlns="urn:orleans">
<Globals>
<StorageProviders>
<Provider Type="Orleans.StorageProvider.Couchbase.CouchbaseStorageProvider" Name="CouchbaseStore" />
</StorageProviders>
...
```

Then register the Couchbase nodes and data buckets configuration in the app.config or web.config within the Silo host project as the following:

```xml
<?xml version="1.0" encoding="utf-8"?>
<configSections>
<section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
</configSections>
<couchbase>
<servers bucket="beer-sample">
<add uri="http://127.0.0.1:8091/pools"/>
</servers>
</couchbase>
...
```

Then from your grain code configure grain storage:

```cs
// define a state interface
public interface IDeviceGrainState : IGrainState
{
string UniqueID { get; set; }
}

// Select the CouchbaseStore as the storage provider for the grain
[StorageProvider(ProviderName="CouchbaseStore")]
public class DeviceGrain : Orleans.Grain<IDeviceGrainState>, DeviceGrain
{
public Task Test(string value)
{
// set the state and save it
this.State.UniqueID = value;
return this.State.WriteStateAsync();
}

}
```

Grains are stored in json format with the following naming convention within the Couchbase Data Bucket:

```
{GrainType}-{GrainId}.json
```

i.e.

```
IoTDevice.Grain1-0.json
```

## License

MIT

0 comments on commit 70bfb03

Please sign in to comment.