Coder Social home page Coder Social logo

Comments (5)

m-wild avatar m-wild commented on June 4, 2024 1

Hi, apologies for the late reply, picking this up now :)

A possible solution, that is more flexible, is to allow for Channels/Operations and Messages to be declared as independent attributes in multiple classes or methods. In this case, each Message Attribute would specify the Operation it belongs to, and when generating the document, it would update/add the message (stored as a collection) in the specified Operation object.

Can you give a code example of how (ideally) this would look for you (as the library user)?
I understand the issue, but I'm not sure exactly what the best user experience looks like.

Thanks

from saunter.

m-wild avatar m-wild commented on June 4, 2024 1

Ok, this looks good.
As I'm really only experienced with AMQP, I didn't understand the potential design differences with Kafka (and I'm sure there will be more differences with other implementations).

I will start working on this now 😀

from saunter.

m-wild avatar m-wild commented on June 4, 2024 1

Hello again, this is now in master.
See ClassAttributesTests for an example https://github.com/tehmantra/saunter/blob/master/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs

This will be available on NuGet v0.1.0-alpha-46
https://www.nuget.org/packages/Saunter/0.1.0-alpha-46

from saunter.

joaopi avatar joaopi commented on June 4, 2024

Thank you for your reply!

I don't have a perfect solution but I think the best is decoupling channels from the message/method, but keeping the current solution for backward compatibility.

So for channels, I think it should be possible to declare them either on classes or methods.
Using methods attributes would assume the current behavior of associating the Channel attribute with the Operation/Message.

When a Channel is declared as a class attribute, it would assume there is a channel and it might contain multiple messages under the same channel.
By design of the asyncapi spec, a channel can only have one producer and one subscriber, the Operation must be declared also as a class attribute.

So it would require a new Message Attribute, associated with a method(?) (or should be other classes, the message classes?).
The Message would need to reference the OperationId as a key, and by doing so it would aggregate all messages related to the Operation/Channel.

Example:

[AsyncApi]
[Channel(TENANT_INSTANCES_TOPIC, Description = TENANT_TOPIC_DESCRIPTION)]
// OperationId can assume the class name if not specified
[SubscribeOperation([OperationId= "TenantMessageConsumer"], Summary = "Subscribe to domains events about tenants.")]
public class TenantMessageConsumer :  ITenantMessageConsumer
{
    internal const string TENANT_INSTANCES_TOPIC = "asw.tenant_service.tenants_history";

    [Message(typeof(TenantCreated), OperationId= "TenantMessageConsumer", Description = "...")]
    void SubscribeTenantCreatedEvent(Guid tenant_id, TenantCreated evnt) {}

    [Message(typeof(TenantUpdated), OperationId= "TenantMessageConsumer", Description = "...")]
    void SubscribeTenantUpdatedEvent(Guid tenant_id, TenantUpdated evnt) {}

    [Message(typeof(TenantRemoved), OperationId= "TenantMessageConsumer", Description = "...")]
    void SubscribeTenantRemovedEvent(Guid tenant_id, TenantRemoved  evnt)  {  }

}

from saunter.

joaopi avatar joaopi commented on June 4, 2024

Thank you so much!

from saunter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.