Ejemplo n.º 1
0
        public Session GetSession()
        {
            var count = Interlocked.Increment(ref _counter);
            var ticks = _dateTimeProvider.GetCurrentTime().Ticks + count;

            var prefix            = BitConverter.GetBytes(ticks);
            var serializedAddress = _addressConversion.SerializeAddress(_address);

            return(new Session(prefix, serializedAddress));
        }
Ejemplo n.º 2
0
        public async Task MapEndPointAsync(EndPointAddress endPoint, TAddress address, CancellationToken cancellation)
        {
            if (endPoint == default)
            {
                throw new ArgumentDefaultException(nameof(endPoint));
            }

            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            if (address.Equals(default(TAddress)))
            {
                throw new ArgumentDefaultException(nameof(address));
            }

            var session = (await _coordinationManager.GetSessionAsync(cancellation)).ToString();
            var path    = GetPath(endPoint, session);

            await _coordinationManager.GetOrCreateAsync(path, _addressConversion.SerializeAddress(address), EntryCreationModes.Ephemeral, cancellation);
        }