-
Notifications
You must be signed in to change notification settings - Fork 18
feat!: separate bindings and allow for custom bindings. #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9d60686
so far so good
VisualBean d837cac
this works
VisualBean 16219b5
PulsarBindings done
VisualBean ce57912
test serialize deserializ
VisualBean 669675d
move bindings
VisualBean c77d87e
finish refactoring deserializers
VisualBean 2cb460c
Bindings work again
VisualBean 854781b
current state
VisualBean 487388d
minor fixings
VisualBean 4d02925
reference resolver stuff
VisualBean 2a99459
much more binding work
VisualBean 417e1a2
Apply suggestions from code review
UlrikSandberg 9c8b721
Update release-internal.yml
VisualBean 1be7efb
fixing warnings and making the package work
VisualBean c06c515
Merge remote-tracking branch 'origin/alex-bindingstake2' into alex-bi…
VisualBean ebee1aa
Update release-package.yml
VisualBean 42cc226
fix usings
VisualBean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,28 @@ | ||
| namespace LEGO.AsyncAPI.Bindings | ||
| { | ||
| using Models.Interfaces; | ||
| using Readers.Interface; | ||
| using Readers.ParseNodes; | ||
|
|
||
| public abstract class Binding<T> : AsyncApiBinding, IBindingParser<T> | ||
| where T : IBinding, new() | ||
| { | ||
| protected void ParseMap<T>( | ||
| MapNode mapNode, | ||
| T domainObject, | ||
| FixedFieldMap<T> fixedFieldMap) | ||
| { | ||
| if (mapNode == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| foreach (var propertyNode in mapNode) | ||
| { | ||
| propertyNode.ParseField(domainObject, fixedFieldMap, null); | ||
| } | ||
| } | ||
|
|
||
| public abstract T LoadBinding(PropertyNode node); | ||
| } | ||
| } |
This file contains hidden or 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,68 @@ | ||
| using LEGO.AsyncAPI.Bindings.Http; | ||
| using LEGO.AsyncAPI.Bindings.Kafka; | ||
| using LEGO.AsyncAPI.Bindings.Pulsar; | ||
| using LEGO.AsyncAPI.Bindings.WebSockets; | ||
| using LEGO.AsyncAPI.Models.Interfaces; | ||
| using LEGO.AsyncAPI.Readers.Interface; | ||
|
|
||
| namespace LEGO.AsyncAPI.Bindings | ||
| { | ||
|
|
||
| public static class BindingsCollection | ||
| { | ||
| public static TCollection Add<TCollection, TItem>( | ||
| this TCollection destination, | ||
| IEnumerable<TItem> source) | ||
| where TCollection : ICollection<TItem> | ||
| { | ||
| ArgumentNullException.ThrowIfNull(destination); | ||
| ArgumentNullException.ThrowIfNull(source); | ||
|
|
||
| if (destination is List<TItem> list) | ||
| { | ||
| list.AddRange(source); | ||
| return destination; | ||
| } | ||
|
|
||
| foreach (var item in source) | ||
| { | ||
| destination.Add(item); | ||
| } | ||
|
|
||
| return destination; | ||
| } | ||
|
|
||
| public static IEnumerable<IBindingParser<IBinding>> All => new List<IBindingParser<IBinding>> | ||
| { | ||
| Pulsar, | ||
| Kafka, | ||
| Http, | ||
| }; | ||
|
|
||
| public static IEnumerable<IBindingParser<IBinding>> Http => new List<IBindingParser<IBinding>> | ||
| { | ||
| new HttpOperationBinding(), | ||
| new HttpMessageBinding() | ||
| }; | ||
|
|
||
| public static IEnumerable<IBindingParser<IBinding>> Websockets => new List<IBindingParser<IBinding>> | ||
| { | ||
| new WebSocketsChannelBinding(), | ||
| }; | ||
|
|
||
| public static IEnumerable<IBindingParser<IBinding>> Kafka => new List<IBindingParser<IBinding>> | ||
| { | ||
| new KafkaServerBinding(), | ||
| new KafkaChannelBinding(), | ||
| new KafkaOperationBinding(), | ||
| new KafkaMessageBinding(), | ||
| }; | ||
|
|
||
| public static IEnumerable<IBindingParser<IBinding>> Pulsar => new List<IBindingParser<IBinding>> | ||
| { | ||
| // Pulsar | ||
| new PulsarServerBinding(), | ||
| new PulsarChannelBinding(), | ||
| }; | ||
| } | ||
| } |
This file contains hidden or 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 LEGO.AsyncAPI.Bindings | ||
| { | ||
| using LEGO.AsyncAPI.Models.Interfaces; | ||
| using LEGO.AsyncAPI.Readers; | ||
| using LEGO.AsyncAPI.Readers.ParseNodes; | ||
|
|
||
| public abstract class ChannelBinding<T> : Binding<T>, IChannelBinding | ||
| where T : IChannelBinding, new() | ||
| { | ||
| protected abstract FixedFieldMap<T> FixedFieldMap { get; } | ||
|
|
||
| public override T LoadBinding(PropertyNode node) => BindingDeserializer.LoadBinding("ChannelBinding", node.Value, this.FixedFieldMap); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.