You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

55 lines
3.3 KiB

  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. namespace Cap.Consistency
  5. {
  6. /// <summary>
  7. /// Provides an abstraction for a store which manages kafka consistent message.
  8. /// </summary>
  9. /// <typeparam name="TMessage"></typeparam>
  10. public interface IConsistentMessageStore<TMessage> : IDisposable where TMessage : class
  11. {
  12. /// <summary>
  13. /// Finds and returns a message, if any, who has the specified <paramref name="messageId"/>.
  14. /// </summary>
  15. /// <param name="messageId">The message ID to search for.</param>
  16. /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
  17. /// <returns>
  18. /// The <see cref="Task"/> that represents the asynchronous operation, containing the message matching the specified <paramref name="messageId"/> if it exists.
  19. /// </returns>
  20. Task<TMessage> FindByIdAsync(string messageId, CancellationToken cancellationToken);
  21. /// <summary>
  22. /// Creates a new message in a store as an asynchronous operation.
  23. /// </summary>
  24. /// <param name="message">The message to create in the store.</param>
  25. /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
  26. /// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns>
  27. Task<OperateResult> CreateAsync(TMessage message, CancellationToken cancellationToken);
  28. /// <summary>
  29. /// Updates a message in a store as an asynchronous operation.
  30. /// </summary>
  31. /// <param name="message">The message to update in the store.</param>
  32. /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
  33. /// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns>
  34. Task<OperateResult> UpdateAsync(TMessage message, CancellationToken cancellationToken);
  35. /// <summary>
  36. /// Deletes a message from the store as an asynchronous operation.
  37. /// </summary>
  38. /// <param name="message">The message to delete in the store.</param>
  39. /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
  40. /// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns>
  41. Task<OperateResult> DeleteAsync(TMessage message, CancellationToken cancellationToken);
  42. /// <summary>
  43. /// Gets the ID for a message from the store as an asynchronous operation.
  44. /// </summary>
  45. /// <param name="message">The message whose ID should be returned.</param>
  46. /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
  47. /// <returns>A <see cref="Task{TResult}"/> that contains the ID of the message.</returns>
  48. Task<string> GetMessageIdAsync(TMessage message, CancellationToken cancellationToken);
  49. }
  50. }