using Microsoft.ApplicationInsights.Channel;
using System.Threading.Channels;

namespace PlanTempus.Core.Telemetry
{
    public class MessageChannel : IMessageChannel<ITelemetry>
    {
        private readonly Channel<ITelemetry> _channel;

        public MessageChannel()
        {
            _channel = Channel.CreateUnbounded<ITelemetry>();
        }

        public ChannelWriter<ITelemetry> Writer => _channel.Writer;
        public ChannelReader<ITelemetry> Reader => _channel.Reader;

        public void Dispose()
        {
            _channel.Writer.Complete();
        }
    }
}
