Skip to content
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

Explore - Rewrite Fluent API #330

Closed
wants to merge 3 commits into from
Closed

Explore - Rewrite Fluent API #330

wants to merge 3 commits into from

Conversation

adammorr
Copy link
Contributor

@adammorr adammorr commented Aug 16, 2017

@slang25 first pass of exploring/rewriting the fluent API and splitting out/changing the underlying bus implementations

// Configure bus (regions, dependencies etc.)
var configuredBus = new BusBuilder().UsingAws(cfg =>
{
    cfg.UseRegions("eu-west-1", "eu-central-1");
    cfg.ConfigureDependencies(dep =>
    {
        dep.MessageMonitor = new NullOpMessageMonitor();
    });
});

// Publisher
var publisher = await configuredBus.CreatePublishers()
    .AddTopicPublisher<MessageOne>(cfg =>
    {
        cfg.TopicNameOverride = "override-topic-name";
        cfg.AdditionalSubscribers = new[] {"123", "456", "789"};
    })
    .AddQueuePublisher<MessageTwo>(cfg =>
    {
        cfg.QueueNameOverride = "override-queue-name";
        cfg.DeliveryDelaySeconds = 10;
        cfg.ErrorQueueOptOut = true;
        cfg.ErrorQueueRetentionPeriodSeconds = 300;
        cfg.MessageRetentionSeconds = 30;
        cfg.RetryCountBeforeSendingToErrorQueue = 8;
        cfg.VisibilityTimeoutSeconds = 30;
    })
    .BuildAsync();

await publisher.PublishAsync(new MessageOne());

// Subscriber
var subscriber = await configuredBus.CreateSubscribers()
    .AddTopicSubscriber(cfg =>
    {
        cfg.TopicNameOverride = "override-topic-name";
    })
    .WithHandler(new MessageOneHandler())
    .AddQueueSubscriber(cfg =>
    {
        cfg.QueueNameOverride = "override-queue-name";
    })
    .WithHandler(new MessageTwoHandler())
    .BuildAsync();

subscriber.StartListening();
subscriber.StopListening();

@adammorr adammorr added the DNMY label Aug 16, 2017
@adammorr adammorr changed the title Rewrite most things Explore - rewrite most things Aug 16, 2017
@adammorr adammorr changed the title Explore - rewrite most things Explore - Rewrite Fluent API Aug 16, 2017
@slang25 slang25 mentioned this pull request Aug 22, 2017
6 tasks
@jaimalchohan
Copy link
Contributor

LGTM 👍

@gerektoolhy
Copy link
Contributor

@stuart-lang

Few things come to my mind. Not necessarily they are related to this PR:
a) AddQueuePublisher and AddTopicPublisher to support Type param as the message type. Easy and not intrusive change.
b) Is it possible to configure globaly bus defaults? E.g. Default retention period. Is this just as easy as modifying the variable in the constants file? (sorry, do not remember the name of the file, but i've seen there is global defaults somewhere)
c) Current issue we have is that it takes somewhat longish to initialize a bus, as each topic and subscriber is initialized. This can be alleviated to some extent by not re-checking if the same queue/topic exists multiple times. Some sort of caching layer during startup would help here. Have not seen existing code, so not sure if this is already done or not.
d) AddQueueSubscriber and accompanying AddTopicSubscriber there's something with these that does not feel right. I know this is more or less of what we have currently. I'll need to download and play around with the fluent interface to come up with something else. Can you ping me please.

@stuart-lang Which branch contains the latest code, i'd like to see if i can come up with some suggestions/improvements to the fluent API.

@AnthonySteele
Copy link
Contributor

Resubmit as a "ready to merge" PR when it's ready to go.
Maybe after v6.0 is out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants