private ValueTask PublishAsync()

in src/Elastic.Channels/BufferedChannelBase.cs [434:450]


	private ValueTask<bool> PublishAsync(IOutboundBuffer<TEvent> buffer)
	{
		async Task<bool> AsyncSlowPathAsync(IOutboundBuffer<TEvent> b)
		{
			var maxRetries = Options.BufferOptions.ExportMaxRetries;
			for (var i = 0; i <= maxRetries; i++)
				while (await OutChannel.Writer.WaitToWriteAsync().ConfigureAwait(false))
					if (OutChannel.Writer.TryWrite(b))
						return true;

			return false;
		}

		return OutChannel.Writer.TryWrite(buffer)
			? new ValueTask<bool>(true)
			: new ValueTask<bool>(AsyncSlowPathAsync(buffer));
	}