magic.data.cql 10.0.19

There is a newer version of this package available.
See the version list below for details.
dotnet add package magic.data.cql --version 10.0.19
NuGet\Install-Package magic.data.cql -Version 10.0.19
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="magic.data.cql" Version="10.0.19" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.data.cql --version 10.0.19
#r "nuget: magic.data.cql, 10.0.19"
#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 magic.data.cql as a Cake Addin
#addin nuget:?package=magic.data.cql&version=10.0.19

// Install magic.data.cql as a Cake Tool
#tool nuget:?package=magic.data.cql&version=10.0.19

CQL IO and logging adapters for Hyperlambda

This data adapter contains alternative NoSQL file system services, implementing IFileService, IFolderService, and IStreamService, allowing you to use as an interchangeable "virtual file system" for cases where you want to have 100% stateless magic instances, which is important if you're using Magic in a Kubernetes cluster or something similar, load balancing invocations, virtually resolving files and folders towards a virtual file system. If you take this path you'll have to configure your "appsettings.json" file such as illustrated further down in this document. The project also contains an ILogger implementation service you can use that will create log entries in a NoSQL based storage of your choice. See below for details about how to configure this.

Configuration

The primary configuration for the project to apply for your "appsettings.json" file can be found below. Notice, the IO and log services requires you to use generic as your cluster name, and you cannot change this.

{
  "magic": {
    "cql": {
      "generic": {
        "host": "127.0.0.1"
      }
    }
  }
}

The above configures the adapter to use 127.0.0.1 as the host for your contact point or cluster. To configure the adapter to store files and folders inside of its CQL based database, you can alternatively add something such as follows to your "appsettings.json" file.

{
  "magic": {
    "io": {
      "file-service": "magic.data.cql.io.CqlFileService",
      "folder-service": "magic.data.cql.io.CqlFolderService",
      "stream-service": "magic.data.cql.io.CqlStreamService"
    }
  }
}

If you want to use a CQL based log implementation, you'll have to configure Magic to use the NoSQL ILogger service such as follows.

{
  "magic": {
    "logging": {
      "service": "magic.data.cql.logging.Logger"
    }
  }
}

Schema

To use the alternative CQL based file storage system you'll have to create your "magic" keyspace and its "files" table as follows.

create keyspace if not exists magic with replication = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 5 };

use magic;

create table if not exists files(
   tenant text,
   cloudlet text,
   folder text,
   filename text,
   content blob,
   primary key((tenant, cloudlet), folder, filename));

To use the alternative CQL based log implementation you'll have to create your "magic" keyspace and its "log_entries" table as follows.

create keyspace if not exists magic with replication = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 5 };

use magic;

create table if not exists log_entries(
   tenant text,
   cloudlet text,
   created timeuuid,
   type text,
   content text,
   exception text,
   primary key((tenant, cloudlet), created)) with clustering order by (created desc);

alter table log_entries with default_time_to_live = 604800;

Notice - The above setting for TTL implies log items will be automatically deleted after 7 days, since 604,800 seconds implies 7 days. Depending upon your needs you might want to increase this setting.

Adding existing files into keyspace

The following Hyperlambda will insert all your existing files and folders into your cluster keyspace, allowing you to play around with an existing CQL file system implementation. Notice, you'll have to change the [.tenant] and [.cloudlet] values to resemble the absolute root folder for your Magic backend. The values in the file below is obviously just an example of how it might look like if you've got the files on a Mac within your "Documents" folder.

/*
 * Inserts all dynamic files and folders into the magic CQL database.
 */
cql.connect:[generic|magic]

   /*
    * The root folder where your Magic backend is running.
    */
   .tenant:Users
   .cloudlet:"thomashansen/Documents/projects/magic/magic/backend"

   /*
    * Inserting root folder.
    */
   cql.execute:"insert into files (tenant, cloudlet, folder, filename) values (:tenant, :cloudlet, '/files/', '')"
      tenant:x:@.tenant
      cloudlet:x:@.cloudlet

   /*
    * Inserting appsettings.json and its folder.
    */
   config.load
   convert:x:-
      type:bytes
   cql.execute:"insert into files (tenant, cloudlet, folder, filename, content) values (:tenant, :cloudlet, '/config/', 'appsettings.json', :config)"
      tenant:x:@.tenant
      cloudlet:x:@.cloudlet
      config:x:@convert
   cql.execute:"insert into files (tenant, cloudlet, folder, filename) values (:tenant, :cloudlet, '/config/', '')"
      tenant:x:@.tenant
      cloudlet:x:@.cloudlet

   /*
    * Inserting folders.
    */
   io.folder.list-recursively:/
      display-hidden:true
   for-each:x:-/*

      strings.concat
         .:/files
         get-value:x:@.dp/#
      
      cql.execute:"insert into files (tenant, cloudlet, folder, filename) values (:tenant, :cloudlet, :folder, '')"
         tenant:x:@.tenant
         cloudlet:x:@.cloudlet
         folder:x:@strings.concat

   /*
    * Inserting files.
    */
   io.file.list-recursively:/
      display-hidden:true
   for-each:x:-/*

      io.file.load.binary:x:@.dp/#
   
      strings.split:x:@.dp/#
         .:/
      unwrap:x:+
      .filename:x:@strings.split/0/-
      remove-nodes:x:@strings.split/0/-
      strings.join:x:@strings.split/*
         .:/
      strings.concat
         .:/files/
         get-value:x:@strings.join
         .:/
      strings.replace:x:-
         .://
         .:/
      cql.execute:"insert into files (tenant, cloudlet, folder, filename, content) values (:tenant, :cloudlet, :folder, :filename, :content)"
         tenant:x:@.tenant
         cloudlet:x:@.cloudlet
         folder:x:@strings.replace
         filename:x:@.filename
         content:x:@io.file.load.binary

remove-nodes:x:../**/io.folder.list-recursively/*
remove-nodes:x:../**/io.file.list-recursively/*

Project website

The source code for this repository can be found at github.com/polterguy/magic.data.cql, and you can provide feedback, provide bug reports, etc at the same place.

Quality gates

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Coverage
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
14.5.7 456 12/13/2022
14.5.5 519 12/6/2022
14.5.1 442 11/23/2022
14.5.0 408 11/18/2022
14.4.5 490 10/22/2022
14.4.1 408 10/22/2022
14.4.0 441 10/17/2022
14.3.1 575 9/12/2022
14.3.0 383 9/10/2022
14.1.3 667 8/7/2022
14.1.2 405 8/7/2022
14.1.1 390 8/7/2022
14.0.14 454 7/26/2022
14.0.12 433 7/24/2022
14.0.11 403 7/23/2022
14.0.10 412 7/23/2022
14.0.9 395 7/23/2022
14.0.8 486 7/17/2022
14.0.5 540 7/11/2022
14.0.4 669 7/6/2022
14.0.3 642 7/2/2022
14.0.2 588 7/2/2022
14.0.0 801 6/25/2022
13.4.0 2,002 5/31/2022
13.3.4 1,375 5/9/2022
13.3.1 666 5/1/2022
13.3.0 632 5/1/2022
13.2.0 1,125 4/21/2022
13.1.0 982 4/7/2022
13.0.0 666 4/5/2022
11.0.5 1,357 3/2/2022
11.0.4 702 2/22/2022
11.0.3 692 2/9/2022
11.0.2 717 2/6/2022
11.0.1 714 2/5/2022
10.0.21 715 1/28/2022
10.0.20 692 1/27/2022
10.0.19 690 1/23/2022