Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1e9b6bb
adding docs/.gitignore
naskio Jan 28, 2023
d97af61
moving logo/ to docs/static/
naskio Jan 28, 2023
493a91f
adding favicon
naskio Jan 29, 2023
e7071ec
bootstrapping website
naskio Jan 29, 2023
e809bbd
moving logo/ to project/logo/
naskio Jan 29, 2023
271642f
adding GR-OSS logo
naskio Jan 29, 2023
eea9b53
fix Consul.NET IconLogo-Color background
naskio Jan 29, 2023
187ba02
adding icons
naskio Jan 29, 2023
bb3bb8e
adding dummy blog content
naskio Jan 29, 2023
f2b06fe
adding dummy docs/ content
naskio Jan 29, 2023
61ebdab
WIP: README.md for Website
naskio Jan 29, 2023
8d2c7d9
WIP: Landing Page
naskio Jan 29, 2023
ea153bf
adding Sidebars definition
naskio Jan 29, 2023
4e46338
WIP: theming according to Consul.NET
naskio Jan 29, 2023
e446062
adding GitHub Banner
naskio Jan 29, 2023
af0cd88
moving GitHub Banner
naskio Jan 29, 2023
2e22405
WIP: adding Docusaurus Config
naskio Jan 29, 2023
caa1c86
WIP: staging config
naskio Jan 29, 2023
8bc3e60
WIP: adding deploy website Workflow
naskio Jan 29, 2023
33b78c6
fix deployWebste workflow
naskio Jan 29, 2023
2dffb8f
changing GR logo color
naskio Jan 29, 2023
446f1fd
updating footer
naskio Feb 10, 2023
c8b20ba
removing the blog/
naskio Feb 17, 2023
def2da2
updating repo README.md
naskio Feb 17, 2023
5c91d78
updating README.md
naskio Feb 17, 2023
5a787fd
updating README.md
naskio Feb 17, 2023
e0d1957
updating README.md
naskio Feb 17, 2023
857f155
updating footer: Stack Overflow link
naskio Feb 17, 2023
d0d3010
cleaning repo: README.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md
naskio Feb 17, 2023
34a75d7
adding content to docs/
naskio Feb 17, 2023
8b87ef2
updating landing page
naskio Feb 17, 2023
a1edd6a
fix stars button
naskio Feb 17, 2023
aa5cd5f
fix GR-OSS website description
naskio Feb 17, 2023
155449e
upgrading docusaurus
naskio Feb 17, 2023
33d15bd
fix build process + broken links
naskio Feb 17, 2023
a6c4d74
moving feedz badge
naskio Feb 17, 2023
abf3e0a
updating website README.md
naskio Feb 18, 2023
62d0434
updating website README.md
naskio Feb 18, 2023
655e503
updating README.md
naskio Feb 18, 2023
8c2f490
updating README.md
naskio Feb 18, 2023
e59e880
fix call to Actions in landing page
naskio Feb 18, 2023
0b408da
fix compatibility table
naskio Feb 22, 2023
5a60860
removing useless yarn commands
naskio Feb 24, 2023
a4c6e7b
updating Stack Overflow url (tags: c# + consul)
naskio Feb 24, 2023
7e366d0
clean comments + fix EditBaseUrl
naskio Feb 24, 2023
6c1502f
removing link from feedz badge
naskio Feb 26, 2023
138f387
making versions dynamic (defined in docusaurus.config.js + CI)
naskio Feb 26, 2023
d2c2545
extracting version in CI from most recent tag
naskio Mar 9, 2023
b05b78c
updating README.md
naskio Mar 9, 2023
2e52100
clean workflow
naskio Mar 9, 2023
c14cd30
clean GitHub Actions workflow
naskio Mar 9, 2023
7b03864
fix docs/README.md
naskio Mar 9, 2023
23833db
FIX docs/: website + email address
naskio Mar 9, 2023
916eb98
cleaning code: removing comments
naskio Mar 9, 2023
251e194
explicit default-branch "master"
naskio Mar 14, 2023
6b31a3a
Merge branch 'master' into documentation
jgiannuzzi Mar 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Deploy website to Pages

on:
push: # Runs on pushes targeting the default branch
branches:
- master
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab

permissions: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
contents: read
pages: write
id-token: write

concurrency: # Allow one concurrent deployment
group: "pages"
cancel-in-progress: true

defaults: # Default to bash
run:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Number of commits to fetch. 0 indicates all history for all branches and tags.
- name: Get current version
id: version
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: "X.X.X" # Optional fallback tag to use when no tag can be found
- name: Detect package manager
id: detect-package-manager
working-directory: ./docs
run: |
if [ -f "yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine packager manager"
exit 1
fi
- name: change directory
run: cd ./docs
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: docs/yarn.lock
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Restore cache
uses: actions/cache@v3
with:
path: |
docs/build
docs/.docusaurus
key: ${{ runner.os }}-docusaurus-build-${{ hashFiles('docs/build') }}
restore-keys: |
${{ runner.os }}-docusaurus-build-
- name: Install dependencies
working-directory: ./docs
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build
working-directory: ./docs
env:
CONSUL_DOT_NET_VERSION: ${{ steps.version.outputs.tag }}
run: ${{ steps.detect-package-manager.outputs.manager }} run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./docs/build

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
236 changes: 35 additions & 201 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,231 +1,65 @@
<p align="left"><img width="500" height="250" src=logo/svg/Consul.NET_SignatureLogo_RGB-Black.svg alt="Consul.NET"/></p>
[![Consul.NET](https://user-images.githubusercontent.com/18899702/219622225-1fda8125-ed7e-4e07-8281-64d3cd5368b8.png)](https://consuldot.net/)

[![CI](https://github.com/G-Research/consuldotnet/actions/workflows/ci.yml/badge.svg?branch=master&event=push)](https://github.com/G-Research/consuldotnet/actions/workflows/ci.yml?query=branch%3Amaster+event%3Apush)
[![NuGet](https://img.shields.io/nuget/vpre/consul)](https://www.nuget.org/packages/Consul/absoluteLatest)
[![Feedz](https://img.shields.io/feedz/vpre/consuldotnet/preview/consul)](#preview-versions)
[![Downloads](https://img.shields.io/nuget/dt/consul?label=Downloads)](https://www.nuget.org/packages/Consul/absoluteLatest)

[![Contribute with GitPod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/G-Research/consuldotnet/)
[![Contributors](https://img.shields.io/github/contributors/G-Research/consuldotnet.svg?label=Contributors)](https://github.com/G-Research/consuldotnet/graphs/contributors)
[![License](https://img.shields.io/github/license/G-Research/consuldotnet.svg?label=License)](https://github.com/G-Research/consuldotnet/blob/master/LICENSE)
[![Twitter Follow](https://img.shields.io/twitter/follow/oss_gr.svg?label=Twitter)](https://twitter.com/oss_gr)

* Consul API: [v1.6.10](https://github.com/hashicorp/consul/tree/v1.6.10/api)
* .NET: >= 4.6.1 - .NET Core: >= 2.0.0
[![Consul API: 1.6.10](https://img.shields.io/badge/Consul%20API%20version-1.6.10-red)](https://github.com/hashicorp/consul/tree/v1.6.10/api)
![.NET: >= 4.6.1](https://img.shields.io/badge/.NET%20version-%3E=4.6.1-blue)
![.NET Core: >= 2.0.0](https://img.shields.io/badge/.NET%20Core%20version-%3E=2.0.0-blueviolet)

Consul.NET is a .NET port of the Go Consul API, but reworked to use .NET
idioms such as Tasks/CancellationTokens instead of Goroutines/Channels.
The majority of the calls directly track the [HTTP
API](https://www.consul.io/docs/agent/http.html), but this API does have
additional functionality that is provided in the Go API, like Locks and
Semaphores.
Consul.NET is a .NET client library for the [Consul HTTP API](https://www.consul.io/).

## Example
> *For further information, please visit the [🌐 Consul.NET website](https://consuldot.net/).*

You'll need a running Consul Server on your local machine, or a Consul
Agent connected to a Consul Server cluster. To run a local server:
## 📢 Introduction

1. [Download a copy](https://www.consul.io/downloads.html) of the latest Windows
version and unzip it into the `Consul.Test` folder.
2. Open a command prompt and `cd` to the `Consul.Test` folder.
3. Run `.\consul.exe agent -dev -config-file test_config.json`
Consul.NET is a .NET port of the Go Consul API, but reworked to use .NET idioms such as Tasks/CancellationTokens instead
of Goroutines/Channels. The majority of the calls directly track
the [HTTP API](https://www.consul.io/docs/agent/http.html), but this API does have additional functionality that is
provided in the Go API, like Locks and Semaphores.

This creates a 1-server cluster that operates in "dev" mode (does not
write data to disk) and listens on `127.0.0.1:8500`.
**[📖 Learn more about Consul.NET](https://consuldot.net/)**
• **[📚 Documentation](https://consuldot.net/docs/)**

Once Consul is running (you'll see something like `==> Consul
agent running!`) in your command prompt, then do the following
steps in your project.
## 📦 Installation

Add a reference to the Consul library and add a using statement:
Consul.NET is available as a [NuGet package](https://www.nuget.org/packages/Consul/).

```csharp
using Consul;
```bash
dotnet add package Consul
```

Write a function to talk to the KV store:

```csharp
public static async Task<string> HelloConsul()
{
using (var client = new ConsulClient())
{
var putPair = new KVPair("hello")
{
Value = Encoding.UTF8.GetBytes("Hello Consul")
};

var putAttempt = await client.KV.Put(putPair);

if (putAttempt.Response)
{
var getPair = await client.KV.Get("hello");
return Encoding.UTF8.GetString(getPair.Response.Value, 0,
getPair.Response.Value.Length);
}
return "";
}
}
```

And call it:

```csharp
Console.WriteLine(HelloConsul().GetAwaiter().GetResult());
```

You should see `Hello Consul` in the output of your program. You should
also see the following lines in your command prompt, if you're running
a local Consul server:

```log
[DEBUG] http: Request /v1/kv/hello (6.0039ms)
[DEBUG] http: Request /v1/kv/hello (0)
```

The API just went out to Consul, wrote "Hello Consul" under the key
"hello", then fetched the data back out and wrote it to your prompt.

## Usage

All operations are done using a `ConsulClient` object. First,
instantiate a `ConsulClient` object, which connects to `localhost:8500`,
the default Consul HTTP API port. Once you've got a `ConsulClient`
object, various functionality is exposed as properties under the
`ConsulClient`.

All responses are wrapped in `QueryResponse` and `WriteResponse`
classes, which provide metadata about the request, like how long it
took and the monotonic Consul index when the operation occured.

This API also assumes some knowledge of Consul, including things like
[blocking queries and consistency
modes](https://www.consul.io/docs/agent/http.html)

### ACL

The ACL endpoints are used to create, update, destroy, and query Legacy ACL tokens.

### ACLReplication

The ACLReplication endpoint is used to query the status of ACL Replication.

### Agent

The Agent endpoints are used to interact with the local Consul agent.
Usually, services and checks are registered with an agent which then
takes on the burden of keeping that data synchronized with the cluster.
For example, the agent registers services and checks with the Catalog
and performs anti-entropy to recover from outages.

### AuthMethod

The AuthMethod endpoints are used to create, update, destroy, and query ACL Auth Methods
related to ACL Replication. **These are untested and a place-holder for future changes.**

### Catalog

The Catalog is the endpoint used to register and deregister nodes,
services, and checks. It also provides query endpoints.

### Event

The Event endpoints are used to fire new events and to query the
available events.
**[🚀 Getting Started](https://consuldot.net/docs/category/getting-started)**
• **[🆕 Preview version](https://consuldot.net/docs/next/)**

### Health
## 💕 Community

The Health endpoints are used to query health-related information. They
are provided separately from the Catalog since users may prefer not to
use the optional health checking mechanisms. Additionally, some of the
query results from the Health endpoints are filtered while the Catalog
endpoints provide the raw entries.
If you have any questions, feature requests or bug reports, feel free to open an issue or a pull request.

### KV
- [Website](https://consuldot.net/) (Documentation)
- [GitHub Issues](https://github.com/G-Research/consuldotnet/issues) (Bug reports, feature requests, questions)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/c%23+consul) (Questions)
- [Twitter](https://twitter.com/oss_gr) (Latest news)
- [G-Research Open-Source](https://opensource.gresearch.co.uk/) (More open-source projects)

The KV endpoint is used to access Consul's simple key/value store,
useful for storing service configuration or other metadata.
## 🤝 Contributing

### Policy
We welcome contributions to Consul.NET. Please see
our [Contributing guide](https://consuldot.net/docs/category/contributing) for more information.

The Policy endpoint is used to create, update, delete and read ACL Policies
**[⚡ Contributing](https://consuldot.net/docs/category/contributing)**
• **[📜 Code of Conduct](https://consuldot.net/docs/contributing/code-of-conduct)**

### Role
🙌 Thanks goes to these wonderful people:

The Role endpoint is used to create, update, delete and read ACL Roles

### Query

The Prepared Query endpoints are used to create, update, destroy, and
execute prepared queries. Prepared queries allow you to register a
complex service query and then execute it later via its ID or name to
get a set of healthy nodes that provide a given service.

### Session

The Session endpoints are used to create, destroy, and query sessions.

### Status

The Status endpoints are used to get information about the status of the
Consul cluster. This information is generally very low level and not
often useful for clients.

### Token

The Token endpoint is used to create, update, clone, delete and read ACL Tokens

### Additional Functions

Functionality based on the Consul guides using the available primitives
has been implemented as well, just like the Go API.

### Lock

Lock is used to implement client-side leader election for a distributed
lock. It is an implementation of the [Consul Leader
Election](https://consul.io/docs/guides/leader-election.html) guide.

### Semaphore

Semaphore is used to implement a distributed semaphore using the Consul
KV primitives. It is an implementation of the [Consul Semaphore
](https://www.consul.io/docs/guides/semaphore.html) guide.

## Using with .NET Core and Mono

Both .NET 4.6.1+ and .NET Core 2.0+ are fully supported. Mono is supported on a
best-effort basis. It should compile and run happily on Mono but this is not as
heavily tested as Microsoft .NET stacks. If you have any issues using the Nuget
package or compiling this code with .NET, .NET Core, or Mono, please file a
Github issue with details of the problem.

## Versioning

The version number indicates which version of Consul is supported in terms of API features.
Since Consul has already a version that consists of three numbers (e.g. 1.6.1), the fourth number is necessary to indicate patch releases of Consul.NET.

Please note that NuGet normalizes version numbers, by omitting zero in the fourth part of the version number.
For example version `1.6.1.0` is going to be normalized to `1.6.1`. So to avoid problems, versions and tags with zero in the fourth part should be avoided and explicit three part version should be used instead.

## Preview versions

Preview builds (aka 'nightly' builds) are distributed using https://feedz.io/ for now. To pull preview versions into your project, use the following `NuGet.config` file:

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="consuldotnet-preview" value="https://f.feedz.io/consuldotnet/preview/nuget/index.json" />
</packageSources>
</configuration>
```
[![Contributors](https://contrib.rocks/image?repo=G-Research/consuldotnet)](https://github.com/G-Research/consuldotnet/graphs/contributors)

## Release process
## 📄 License

1. Before making a new release, make sure that the version in [Directory.Build.props](Directory.Build.props) is up to date.
2. Head over to the [CHANGELOG](CHANGELOG.md) file. Replace `## Unreleased` with the new version name and add an additional `## Unreleased` for future changes. Open and merge the PR for these changelog updates.
3. Then, draft a new [GitHub Release](https://github.com/G-Research/consuldotnet/releases) with a list of changes contained in the new version from the [CHANGELOG](CHANGELOG.md).
4. When the draft release is ready, publish it from the GitHub web UI. You can either have GitHub create a new tag for you from the GitHub Release page or push the tag yourself beforehand.
Be aware, clicking **Publish** will trigger GitHub to push a new tag (as specified in the new Release entry, if not created by you already) which will instruct the CI to build and push a new stable release to NuGet.org.
5. If everything went well, congrats, the new versions should be live on NuGet by now. As a final post-release step, bump the minor version in [Directory.Build.props](Directory.Build.props) to the next unreleased version number, so that nightly build versioning can benefit.
Consul.NET is licensed under the [Apache License, Version 2.0](LICENSE).
34 changes: 34 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

# Logs
logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
.npm
*.tgz

# User Specific
.idea/
out/
tmp/
*.tmp
tmp.*
*.tmp.*
Loading