|
| 1 | +// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp> |
| 2 | +// SPDX-License-Identifier: MIT |
| 3 | +using System; |
| 4 | +using System.Buffers; |
| 5 | +using System.Threading; |
| 6 | +using System.Threading.Tasks; |
| 7 | + |
| 8 | +using Smdn.Net.MuninNode.Transport; |
| 9 | + |
| 10 | +namespace Smdn.Net.MuninNode.Protocol; |
| 11 | + |
| 12 | +/// <summary> |
| 13 | +/// Provides an interface that abstracts the handling of data exchange |
| 14 | +/// protocols with <c>munin master</c> in <c>Munin-Node</c>. |
| 15 | +/// </summary> |
| 16 | +/// <seealso href="https://guide.munin-monitoring.org/en/latest/master/network-protocol.html"> |
| 17 | +/// Data exchange between master and node |
| 18 | +/// </seealso> |
| 19 | +public interface IMuninProtocolHandler { |
| 20 | + /// <summary> |
| 21 | + /// Handles the start of a transaction processing requests from <c>munin master</c>. |
| 22 | + /// </summary> |
| 23 | + /// <param name="client"> |
| 24 | + /// The <see cref="IMuninNodeClient"/> to which the request is sent from and |
| 25 | + /// to which the response should be sent back. |
| 26 | + /// </param> |
| 27 | + /// <param name="cancellationToken"> |
| 28 | + /// The <see cref="CancellationToken"/> to monitor for cancellation requests. |
| 29 | + /// </param> |
| 30 | + /// <returns> |
| 31 | + /// The <see cref="ValueTask"/> that represents the asynchronous operation. |
| 32 | + /// </returns> |
| 33 | + /// <exception cref="ArgumentNullException"> |
| 34 | + /// <paramref name="client"/> is <see langword="null"/>. |
| 35 | + /// </exception> |
| 36 | + /// <exception cref="MuninNodeClientDisconnectedException"> |
| 37 | + /// <paramref name="client"/> has been disconnected. |
| 38 | + /// </exception> |
| 39 | + ValueTask HandleTransactionStartAsync( |
| 40 | + IMuninNodeClient client, |
| 41 | + CancellationToken cancellationToken |
| 42 | + ); |
| 43 | + |
| 44 | + /// <summary> |
| 45 | + /// Handles the end of a transaction processing requests from <c>munin master</c>. |
| 46 | + /// </summary> |
| 47 | + /// <param name="client"> |
| 48 | + /// The <see cref="IMuninNodeClient"/> to which the request is sent from and |
| 49 | + /// to which the response should be sent back. |
| 50 | + /// </param> |
| 51 | + /// <param name="cancellationToken"> |
| 52 | + /// The <see cref="CancellationToken"/> to monitor for cancellation requests. |
| 53 | + /// </param> |
| 54 | + /// <returns> |
| 55 | + /// The <see cref="ValueTask"/> that represents the asynchronous operation. |
| 56 | + /// </returns> |
| 57 | + /// <exception cref="ArgumentNullException"> |
| 58 | + /// <paramref name="client"/> is <see langword="null"/>. |
| 59 | + /// </exception> |
| 60 | + /// <exception cref="MuninNodeClientDisconnectedException"> |
| 61 | + /// <paramref name="client"/> has been disconnected. |
| 62 | + /// </exception> |
| 63 | + ValueTask HandleTransactionEndAsync( |
| 64 | + IMuninNodeClient client, |
| 65 | + CancellationToken cancellationToken |
| 66 | + ); |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Handles commands from the <c>munin master</c> and sends back a response. |
| 70 | + /// </summary> |
| 71 | + /// <param name="client"> |
| 72 | + /// The <see cref="IMuninNodeClient"/> to which the request is sent from and |
| 73 | + /// to which the response should be sent back. |
| 74 | + /// </param> |
| 75 | + /// <param name="commandLine"> |
| 76 | + /// The <see cref="ReadOnlySequence{T}"/> representing the command line requested from the <paramref name="client"/>. |
| 77 | + /// </param> |
| 78 | + /// <param name="cancellationToken"> |
| 79 | + /// The <see cref="CancellationToken"/> to monitor for cancellation requests. |
| 80 | + /// </param> |
| 81 | + /// <returns> |
| 82 | + /// The <see cref="ValueTask"/> that represents the asynchronous operation. |
| 83 | + /// </returns> |
| 84 | + /// <exception cref="ArgumentNullException"> |
| 85 | + /// <paramref name="client"/> is <see langword="null"/>. |
| 86 | + /// </exception> |
| 87 | + /// <exception cref="MuninNodeClientDisconnectedException"> |
| 88 | + /// <paramref name="client"/> has been disconnected. |
| 89 | + /// </exception> |
| 90 | + ValueTask HandleCommandAsync( |
| 91 | + IMuninNodeClient client, |
| 92 | + ReadOnlySequence<byte> commandLine, |
| 93 | + CancellationToken cancellationToken |
| 94 | + ); |
| 95 | +} |
0 commit comments