Mathema.Bytecode4CosmosDB 0.2.1

dotnet add package Mathema.Bytecode4CosmosDB --version 0.2.1                
NuGet\Install-Package Mathema.Bytecode4CosmosDB -Version 0.2.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mathema.Bytecode4CosmosDB" Version="0.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mathema.Bytecode4CosmosDB --version 0.2.1                
#r "nuget: Mathema.Bytecode4CosmosDB, 0.2.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Mathema.Bytecode4CosmosDB as a Cake Addin
#addin nuget:?package=Mathema.Bytecode4CosmosDB&version=0.2.1

// Install Mathema.Bytecode4CosmosDB as a Cake Tool
#tool nuget:?package=Mathema.Bytecode4CosmosDB&version=0.2.1                

bytecode4cosmosdb

This is a small library to support bytecode-based requests with Azure Cosmos DB

A word of caution before proceeding: this is very much a work in progress.

At the moment Cosmos DB only supports script-based requests and the result is returned in GraphSON 1.0 format (see https://tinkerpop.apache.org/docs/3.4.1/dev/io/). Cosmos DB is only compatible with Gremlin.NET 3.4, not with the newer version 3.5 and 3.6 (see https://docs.microsoft.com/en-us/azure/cosmos-db/graph/gremlin-support)

This library converts the bytecode-based request into an Groovy string representation using the GroovyTranslator class taken from the Gremlin.NET 3.5 library (https://github.com/apache/tinkerpop/tree/master/gremlin-dotnet). The returned result is serialized into expected result types of the bytecode based request.

Example: create an edge between to nodes:

Edge newEdge = 
         g.V().Has("person", "first_name", fromName)
          .AddE("friends").To(__.V().Has("person", "first_name", toName))
          .Next();

To use the library you simply have to create a connection to Cosmos DB and instead of using the Gremlin.NET provided DriverRemoteConnection class instanciate the CosmosDbRemoteConnection class

Example:

var connectionPoolSettings = new ConnectionPoolSettings
{
   MaxInProcessPerConnection = 32,
   PoolSize = 4,
   ReconnectionAttempts = 3,
   ReconnectionBaseDelay = TimeSpan.FromSeconds(1),
};

CosmosDbGremlinClientBuilder builder =CosmosDbGremlinClientBuilder.BuildClientForServer(cosmosHostname, cosmosPort, cosmosDatabase, cosmosAuthKey, cosmosCollection);

using (var gremlinClient = builder.WithConnectionPoolSettings(connectionPoolSettings).Create())
{
   GraphTraversalSource g = Traversal().WithRemote(new CosmosDbRemoteConnection(gremlinClient));

   // now we can start to use the bytecode based request
   // e.g.
   Edge newEdge = 
         g.V().Has("person", "first_name", fromName)
          .AddE("friends").To(__.V().Has("person", "first_name", toName))
          .Next();

   Console.WriteLine($"Edge : {newEdge}");

   // ... 
}

Resources

The library can be installed via nuget: https://www.nuget.org/packages/Mathema.Bytecode4CosmosDB/

An example application can be found here: https://github.com/MATHEMA-GmbH/DiningByFriends4CosmosDB

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.1 153 9/13/2023
0.2.0 127 9/13/2023
0.1.0-alpha 204 4/19/2022 0.1.0-alpha is deprecated because it is no longer maintained.