-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebhookRelayClient initial implementation.
- Loading branch information
Showing
24 changed files
with
707 additions
and
16 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
libs/aspnet-core/test/AspNetCore.Tests/AspNetCore.Tests.net6.0.v3.ncrunchproject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ProjectConfiguration> | ||
<Settings> | ||
<HiddenComponentWarnings> | ||
<Value>AspNetTestHostCompatibility</Value> | ||
</HiddenComponentWarnings> | ||
</Settings> | ||
</ProjectConfiguration> |
7 changes: 7 additions & 0 deletions
7
libs/aspnet-core/test/AspNetCore.Tests/AspNetCore.Tests.net7.0.v3.ncrunchproject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ProjectConfiguration> | ||
<Settings> | ||
<HiddenComponentWarnings> | ||
<Value>AspNetTestHostCompatibility</Value> | ||
</HiddenComponentWarnings> | ||
</Settings> | ||
</ProjectConfiguration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Webhook Relay Client | ||
|
||
A .NET client for the [Webhook Relay](https://webhookrelay.com) service. | ||
|
||
It creates a websocket connection, authenticates and subscribes to the specified buckets. | ||
|
||
Once the connection is established, it will start receiving messages and writing them to | ||
a channel. | ||
|
||
You can then read messages from the channel and process them however you like. | ||
|
||
If the connection is lost, the client will attempt to reconnect and resubscribe. | ||
|
||
When the client is disposed, it will close the connection and unsubscribe from the buckets. | ||
|
||
It is your responsibility to handle any remaining messages in the channel. | ||
|
||
## Installation | ||
|
||
`dotnet add package Logicality.WebhookRelay.Client` | ||
|
||
## Usage | ||
```csharp | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
|
||
<Import Project="../../src.props" /> | ||
|
||
<PropertyGroup> | ||
<MinVerTagPrefix>webhook-relay-</MinVerTagPrefix> | ||
<MinVerMinimumMajorMinor>0.1</MinVerMinimumMajorMinor> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Logicality.WebhookRelay; | ||
|
||
public enum ClientState | ||
{ | ||
Disconnected, | ||
Connecting, | ||
Connected, | ||
Authenticating, | ||
Authenticated, | ||
Subscribing, | ||
Subscribed, | ||
HandlingMessages, | ||
Disposed, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Logicality.WebhookRelay; | ||
|
||
internal enum ClientTrigger | ||
{ | ||
Connect, | ||
ConnectCompleted, | ||
ConnectFailed, | ||
Authenticate, | ||
AuthenticateSucceeded, | ||
AuthenticationFailed, | ||
Subscribe, | ||
SubscribeCompleted, | ||
HandleMessages, | ||
ConnectionLost, | ||
Dispose | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Logicality.WebhookRelay; | ||
|
||
public class Metadata | ||
{ | ||
public string Id { get; set; } | ||
|
||
[DataMember(Name = "bucket_id")] | ||
public string BucketId { get; set; } | ||
|
||
[DataMember(Name = "bucket_name")] | ||
public string BucketName { get; set; } | ||
|
||
[DataMember(Name = "input_id")] | ||
public string InputId { get; set; } | ||
|
||
[DataMember(Name = "input_name")] | ||
public string InputName { get; set; } | ||
|
||
[DataMember(Name = "output_name")] | ||
public string OutputName { get; set; } | ||
|
||
[DataMember(Name = "output_destination")] | ||
public string OutputDestination { get; set; } | ||
} |
13 changes: 13 additions & 0 deletions
13
libs/webhook-relay/src/WebhookRelay/SnakeCaseNamingPolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Text.Json; | ||
|
||
namespace Logicality.WebhookRelay; | ||
|
||
internal class SnakeCaseNamingPolicy : JsonNamingPolicy | ||
{ | ||
public static SnakeCaseNamingPolicy Instance { get; } = new SnakeCaseNamingPolicy(); | ||
|
||
public override string ConvertName(string name) | ||
{ | ||
return name.ToSnakeCase(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Logicality.WebhookRelay; | ||
|
||
internal static class StringUtils | ||
{ | ||
public static string ToSnakeCase(this string str) | ||
{ | ||
return string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x : x.ToString())).ToLower(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Logicality.WebhookRelay; | ||
|
||
public class WebhookMessage | ||
{ | ||
public Metadata Meta { get; set; } | ||
|
||
public Dictionary<string, string[]> Headers { get; set; } | ||
|
||
public string Query { get; set; } | ||
|
||
public string Body { get; set; } | ||
|
||
public string Method { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" /> | ||
<PackageReference Include="Polly" Version="7.2.3" /> | ||
<PackageReference Include="Stateless" Version="5.13.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.