-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add more useful type exports. #70
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ declare class ProducerError extends Error { | |
constructor(error: { name: string; message: string }); | ||
} | ||
|
||
interface PublishOptions extends amqp.Options.Publish { | ||
interface ProduceOptions extends amqp.Options.Publish { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to decide, which is of the ones we shoul depricate: either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be produce / consume, this is how RabbitMQ clients call it. |
||
routingKey?: string; | ||
rpc?: boolean; | ||
} | ||
|
@@ -45,7 +45,7 @@ declare class Producer { | |
* @param msg The message to publish | ||
* @param options The publish options | ||
*/ | ||
publishOrSendToQueue(queue: string, msg: Buffer, options: PublishOptions): Promise<boolean>; | ||
publishOrSendToQueue(queue: string, msg: Buffer, options: ProduceOptions): Promise<boolean>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method should be private I think |
||
/** | ||
* Start a timer to reject the pending RPC call if no answer is received within the given timeout | ||
* @param queue The queue where the RPC request was sent | ||
|
@@ -61,7 +61,7 @@ declare class Producer { | |
* @param options contain rpc property (if true, enable rpc for this message) | ||
* @return Resolves when message is correctly sent, or when response is received when rpc is enabled | ||
*/ | ||
private checkRpc(queue: string, msg: Buffer, options: PublishOptions): Promise<boolean>; | ||
private checkRpc(queue: string, msg: Buffer, options: ProduceOptions): Promise<boolean>; | ||
/** | ||
* @deprecated Use publish instead | ||
* Ensure channel exists and send message using `checkRpc` | ||
|
@@ -70,18 +70,22 @@ declare class Producer { | |
* @param options message options (persistent, durable, rpc, etc.) | ||
* @return checkRpc response | ||
*/ | ||
produce(queue: string, msg: unknown, options: PublishOptions): Promise<unknown>; | ||
produce(queue: string, msg: unknown, options: ProduceOptions): Promise<unknown>; | ||
/** @see Producer.produce */ | ||
publish(queue: string, msg: unknown, options: PublishOptions): Promise<unknown>; | ||
publish(queue: string, msg: unknown, options: ProduceOptions): Promise<unknown>; | ||
|
||
private _sendToQueue( | ||
queue: string, | ||
message: unknown, | ||
settings: PublishOptions, | ||
settings: ProduceOptions, | ||
currentRetryNumber: number, | ||
): Promise<unknown>; | ||
|
||
private _shouldRetry(error: Error | ProducerError, currentRetryNumber: number): boolean; | ||
} | ||
|
||
declare namespace Producer { | ||
export { ProduceOptions, ProducerError }; | ||
} | ||
|
||
export = Producer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We said we want to deprecate "publish" in favor of "produce", even though currently "produce" is marked deprecated, so I the exported type to "produce".