Skip to content

Commit

Permalink
chore: add pulsar binding (#222)
Browse files Browse the repository at this point in the history
* make pulsar binding

* fix formatting issue

* Update src/Saunter/AsyncApiSchema/v2/Bindings/Pulsar/PulsarServerBinding.cs
  • Loading branch information
VisualBean authored Aug 7, 2024
1 parent 6a3441d commit 1bd5ed1
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Saunter/AsyncApiSchema/v2/Bindings/ChannelBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Saunter.AsyncApiSchema.v2.Bindings.Http;
using Saunter.AsyncApiSchema.v2.Bindings.Kafka;
using Saunter.AsyncApiSchema.v2.Bindings.Mqtt;
using Saunter.AsyncApiSchema.v2.Bindings.Pulsar;

namespace Saunter.AsyncApiSchema.v2.Bindings
{
Expand Down Expand Up @@ -32,5 +33,8 @@ public class ChannelBindings : IChannelBindings

[JsonProperty("mqtt", NullValueHandling = NullValueHandling.Ignore)]
public MqttChannelBinding Mqtt { get; set; }

[JsonProperty("pulsar", NullValueHandling = NullValueHandling.Ignore)]
public PulsarChannelBinding Pulsar { get; set; }
}
}
5 changes: 5 additions & 0 deletions src/Saunter/AsyncApiSchema/v2/Bindings/MessageBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Saunter.AsyncApiSchema.v2.Bindings.Http;
using Saunter.AsyncApiSchema.v2.Bindings.Kafka;
using Saunter.AsyncApiSchema.v2.Bindings.Mqtt;
using Saunter.AsyncApiSchema.v2.Bindings.Pulsar;

namespace Saunter.AsyncApiSchema.v2.Bindings
{
Expand Down Expand Up @@ -32,5 +33,9 @@ public class MessageBindings : IMessageBindings

[JsonProperty("mqtt", NullValueHandling = NullValueHandling.Ignore)]
public MqttMessageBinding Mqtt { get; set; }

[JsonProperty("pulsar", NullValueHandling = NullValueHandling.Ignore)]
public PulsarMessageBinding Pulsar { get; set; }

}
}
4 changes: 4 additions & 0 deletions src/Saunter/AsyncApiSchema/v2/Bindings/OperationBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Saunter.AsyncApiSchema.v2.Bindings.Http;
using Saunter.AsyncApiSchema.v2.Bindings.Kafka;
using Saunter.AsyncApiSchema.v2.Bindings.Mqtt;
using Saunter.AsyncApiSchema.v2.Bindings.Pulsar;

namespace Saunter.AsyncApiSchema.v2.Bindings
{
Expand Down Expand Up @@ -32,5 +33,8 @@ public class OperationBindings : IOperationBindings

[JsonProperty("mqtt", NullValueHandling = NullValueHandling.Ignore)]
public MqttOperationBinding Mqtt { get; set; }

[JsonProperty("pulsar", NullValueHandling = NullValueHandling.Ignore)]
public PulsarOperationBinding Pulsar { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace Saunter.AsyncApiSchema.v2.Bindings.Pulsar
{
/// <remarks>
/// See: https://github.com/asyncapi/bindings/tree/master/pulsar#channel-binding-object
/// </remarks>
public class PulsarChannelBinding
{
/// <summary>
/// The version of this binding. If omitted, "latest" MUST be assumed.
/// </summary>
[JsonProperty("bindingVersion", NullValueHandling = NullValueHandling.Ignore)]
public string BindingVersion { get; set; }

/// <summary>
/// The namespace associated with the topic.
/// </summary>
[JsonProperty("namespace", NullValueHandling = NullValueHandling.Ignore)]
public string Namespace { get; set; }

/// <summary>
/// persistence of the topic in Pulsar persistent or non-persistent.
/// </summary>
[JsonProperty("persistence", NullValueHandling = NullValueHandling.Ignore)]
public Persistence? Persistence { get; set; }

/// <summary>
/// Topic compaction threshold given in bytes.
/// </summary>
[JsonProperty("compaction", NullValueHandling = NullValueHandling.Ignore)]
public int? Compaction { get; set; }

/// <summary>
/// A list of clusters the topic is replicated to.
/// </summary>
[JsonProperty("geoReplication", NullValueHandling = NullValueHandling.Ignore)]
public IList<string> GeoReplication { get; set; }

/// <summary>
/// Topic retention policy.
/// </summary>
[JsonProperty("retention", NullValueHandling = NullValueHandling.Ignore)]
public RetentionDefinition Retention { get; set; }

/// <summary>
/// Message Time-to-live in seconds.
/// </summary>
[JsonProperty("ttl", NullValueHandling = NullValueHandling.Ignore)]
public int? TTL { get; set; }

/// <summary>
/// When Message deduplication is enabled, it ensures that each message produced on Pulsar topics is persisted to disk only once.
/// </summary>
[JsonProperty("deduplication", NullValueHandling = NullValueHandling.Ignore)]
public bool? Deduplication { get; set; }
}

public enum Persistence
{
[EnumMember(Value = "persistent")]
Persistent,
[EnumMember(Value = "non-persistent")]
NonPersistent,
}

public class RetentionDefinition
{
/// <summary>
/// Time given in Minutes. 0 = Disable message retention (by default).
/// </summary>
[JsonProperty("time", NullValueHandling = NullValueHandling.Ignore)]
public int Time { get; set; }

/// <summary>
/// Size given in MegaBytes. 0 = Disable message retention (by default).
/// </summary>
[JsonProperty("size", NullValueHandling = NullValueHandling.Ignore)]
public int Size { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Saunter.AsyncApiSchema.v2.Bindings.Pulsar
{
/// <summary>
/// This object MUST NOT contain any properties. Its name is reserved for future use.
/// </summary>
/// <remarks>
/// See: https://github.com/asyncapi/bindings/blob/master/pulsar/README.md#message-binding-object
/// </remarks>
public class PulsarMessageBinding
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Saunter.AsyncApiSchema.v2.Bindings.Pulsar
{
/// <summary>
/// This object MUST NOT contain any properties. Its name is reserved for future use.
/// </summary>
/// <remarks>
/// See: https://github.com/asyncapi/bindings/blob/master/pulsar/README.md#operation-binding-object
/// </remarks>
public class PulsarOperationBinding
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace Saunter.AsyncApiSchema.v2.Bindings.Pulsar
{
/// <remarks>
/// See: https://github.com/asyncapi/bindings/tree/master/pulsar#server-binding-object
/// </remarks>
public class PulsarServerBinding
{
/// <summary>
/// The pulsar tenant. If omitted, "public" must be assumed.
/// </summary>
[JsonProperty("tenant", NullValueHandling = NullValueHandling.Ignore)]
public string Tenant { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Saunter/AsyncApiSchema/v2/Bindings/Pulsar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/asyncapi/bindings/blob/master/pulsar/README.md
4 changes: 4 additions & 0 deletions src/Saunter/AsyncApiSchema/v2/Bindings/ServerBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Saunter.AsyncApiSchema.v2.Bindings.Http;
using Saunter.AsyncApiSchema.v2.Bindings.Kafka;
using Saunter.AsyncApiSchema.v2.Bindings.Mqtt;
using Saunter.AsyncApiSchema.v2.Bindings.Pulsar;

namespace Saunter.AsyncApiSchema.v2.Bindings
{
Expand Down Expand Up @@ -32,5 +33,8 @@ public class ServerBindings : IServerBindings

[JsonProperty("mqtt", NullValueHandling = NullValueHandling.Ignore)]
public MqttServerBinding Mqtt { get; set; }

[JsonProperty("pulsar", NullValueHandling = NullValueHandling.Ignore)]
public PulsarServerBinding Pulsar { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Linq;
using System.Reflection;
using Saunter.AsyncApiSchema.v2;
using Saunter.Attributes;
using Saunter.Generation;
using Shouldly;
using Xunit;
using System.Linq;

namespace Saunter.Tests.Generation.DocumentGeneratorTests
{
Expand Down

0 comments on commit 1bd5ed1

Please sign in to comment.