GitRCFS 1.3.1

dotnet add package GitRCFS --version 1.3.1                
NuGet\Install-Package GitRCFS -Version 1.3.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="GitRCFS" Version="1.3.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GitRCFS --version 1.3.1                
#r "nuget: GitRCFS, 1.3.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 GitRCFS as a Cake Addin
#addin nuget:?package=GitRCFS&version=1.3.1

// Install GitRCFS as a Cake Tool
#tool nuget:?package=GitRCFS&version=1.3.1                

GitRCFS - Git Remote Config Filesystem

What is GitRCFS?

GitRCFS offers a lightweight option to synchronize an application's configuration & data files with a remote git repository. This library provides a simple api to use a git repository to access readonly configuration files.

Why is this useful?

There are 2 main benefits to using remote git repositories for configuration file hosting.

  1. GitRCFS enables configuration files to be synced across numerous different servers / devices. This saves the hassle of updating configuration files manually, and offers a single place to manage config files.
  2. Another benefit is due to using Git as a version control, as a result, GitRCFS inherits all the benefits of Git. This way, config files could be shared across teams, rolled back, and be used in a much more flexible way.

Using GitRCFS

The GitRCFS library is extremely simple to use.

First create a FileRepository,

var repo = new FileRepository("https://github.com/encodeous/gitrcfstest",
    branch: "main", accessToken: "<your-token>", updateFrequencyMs: 5000);

You can optionally specify an access token, the branch to access the configuration files, and how frequently to check for configuration updates.

To access a file in the filesystem, there are 2 main ways:

  1. Use the / operator to combine a path
    var configFile = repo / "config-dir" / "config.json";
    
  2. Use the [] operator to select a path
    var configFile = repo["config-dir/config.json"];
    

All files and directories are of the type RcfsNode

Through this type, it is possible to listen for file changes, iterate the children of directories, and get the data from files.

Samples

Here are some code snippets showing the usage of GitRCFS.

Read data from repo

// simple use case to read data from a repo:
var repo = new FileRepository("https://github.com/encodeous/gitrcfstest");
Console.WriteLine($"File content from repo: \"{repo["folder/file-in-folder.txt"].GetStringData()}\"");

Reading serialized data from repo

// deserializing a file into a C# class
var repo = new FileRepository("https://github.com/encodeous/gitrcfstest");
Console.WriteLine($"Time is {repo["serialized.json"].DeserializeData<DateTime>()}");

Monitoring repo for changes

// monitor for changes
var repo = new FileRepository("https://github.com/encodeous/gitrcfstest");
var file = repo["folder/file-in-folder.txt"];
Console.WriteLine($"Initial file content from repo: \"{file.GetStringData()}\"");
// file changed event handler
file.ContentsChanged += (_,_) =>
{
    Console.WriteLine($"New file content: \"{file.GetStringData()}\"");
};

Authenticating

// simple use case to read data from a repo when logged in:
var repo = new FileRepository("https://github.com/encodeous/gitrcfstest", username: "user", password: "password");
Console.WriteLine($"File content from repo: \"{repo["folder/file-in-folder.txt"].GetStringData()}\"");
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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
1.3.1 144 2/3/2024
1.3.0 109 2/3/2024
1.2.0 104 2/3/2024
1.1.0 180 1/4/2024
0.1.0 537 2/20/2022
0.0.1 385 6/28/2021