-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Publisher First version --------- Signed-off-by: Gabriele Santomaggio <g.santomaggio@gmail.com>
- Loading branch information
1 parent
7a43277
commit 73653a9
Showing
31 changed files
with
997 additions
and
164 deletions.
There are no files selected for viewing
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
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 @@ | ||
namespace RabbitMQ.AMQP.Client; | ||
|
||
public class InvalidAddressException(string message) : Exception(message); | ||
|
||
public interface IAddressBuilder<out T> | ||
{ | ||
|
||
T Exchange(string exchange); | ||
|
||
T Queue(string queue); | ||
|
||
T Key(string key); | ||
} |
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
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
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,26 @@ | ||
namespace RabbitMQ.AMQP.Client; | ||
|
||
public class PublisherException(string message) : Exception(message); | ||
|
||
public enum OutcomeState | ||
{ | ||
Accepted, | ||
Failed, | ||
} | ||
|
||
public class OutcomeDescriptor(ulong code, string description, OutcomeState state, Error? error) | ||
{ | ||
public OutcomeState State { get; internal set; } = state; | ||
public ulong Code { get; internal set; } = code; | ||
public string Description { get; internal set; } = description; | ||
|
||
public Error? Error { get; internal set; } = error; | ||
} | ||
|
||
public delegate void OutcomeDescriptorCallback(IMessage message, OutcomeDescriptor outcomeDescriptor); | ||
|
||
public interface IPublisher : IClosable | ||
{ | ||
Task Publish(IMessage message, | ||
OutcomeDescriptorCallback outcomeCallback); // TODO: Add CancellationToken and callBack | ||
} |
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 RabbitMQ.AMQP.Client; | ||
|
||
public interface IPublisherBuilder : IAddressBuilder<IPublisherBuilder> | ||
{ | ||
IPublisherBuilder PublishTimeout(TimeSpan timeout); | ||
|
||
IPublisherBuilder MaxInflightMessages(int maxInFlight); | ||
IPublisher Build(); | ||
} |
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
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,27 @@ | ||
namespace RabbitMQ.AMQP.Client.Impl; | ||
|
||
public class AmqpClosedException(string message) : Exception(message); | ||
|
||
public abstract class AbstractClosable : IClosable | ||
{ | ||
public State State { get; internal set; } = State.Closed; | ||
public abstract Task CloseAsync(); | ||
protected void ThrowIfClosed() | ||
{ | ||
if (State == State.Closed) | ||
{ | ||
throw new AmqpClosedException(GetType().Name); | ||
} | ||
} | ||
|
||
|
||
protected void OnNewStatus(State newState, Error? error) | ||
{ | ||
if (State == newState) return; | ||
var oldStatus = State; | ||
State = newState; | ||
ChangeState?.Invoke(this, oldStatus, newState, error); | ||
} | ||
|
||
public event IClosable.LifeCycleCallBack? ChangeState; | ||
} |
Oops, something went wrong.