コード例 #1
0
        public async Task <IEntry> GetOrCreateAsync(string path, byte[] value, EntryCreationModes modes = EntryCreationModes.Default, CancellationToken cancellation = default)
        {
            var result = await _coordinationManager.GetOrCreateAsync(CoordinationEntryPath.FromEscapedPath(path.AsMemory()), value, modes, cancellation);

            if (result == null)
            {
                return(null);
            }

            return(new Entry((Proxy <CoordinationManagerSkeleton>) this, result));
        }
コード例 #2
0
        public async Task <IEntry> GetAsync(string path, CancellationToken cancellation = default)
        {
            var result = await _coordinationManager.GetAsync(CoordinationEntryPath.FromEscapedPath(path.AsMemory()), cancellation);

            if (result == null)
            {
                return(null);
            }

            return(new Entry((Proxy <CoordinationManagerSkeleton>) this, result));
        }
コード例 #3
0
        public async ValueTask <IEntry> GetOrCreateAsync(CoordinationEntryPath path, ReadOnlyMemory <byte> value, EntryCreationModes modes = EntryCreationModes.Default, CancellationToken cancellation = default)
        {
            var proxy = await GetProxyAsync(cancellation);

            if (!(await proxy.ExecuteAsync(p => p.GetOrCreateAsync(path.EscapedPath.ConvertToString(), value.ToArray(), modes, cancellation)) is CoordinationManagerSkeleton.Entry entry))
            {
                return(null);
            }

            entry.SetCoordinationManagerStub(this, proxy);

            return(entry);
        }
コード例 #4
0
        public async ValueTask <IEntry> GetAsync(CoordinationEntryPath path, CancellationToken cancellation = default)
        {
            var proxy = await GetProxyAsync(cancellation);

            if (!(await proxy.ExecuteAsync(p => p.GetAsync(path.EscapedPath.ConvertToString(), cancellation)) is CoordinationManagerSkeleton.Entry entry))
            {
                return(null);
            }

            entry.SetCoordinationManagerStub(this, proxy);

            return(entry);
        }
コード例 #5
0
        public ClientConnectionManager(ICoordinationManager coordinationManager,
                                       IDateTimeProvider dateTimeProvider,
                                       IOptions <ClientConnectionOptions> clientConnectionOptionsAccessor,
                                       IOptions <ClientConnectionManagerOptions> clientConnectionManagerOptionsAccessor,
                                       ILogger <ClientConnectionManager> logger = null)
        {
            if (coordinationManager == null)
            {
                throw new ArgumentNullException(nameof(coordinationManager));
            }

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

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

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

            _coordinationManager = coordinationManager;
            _dateTimeProvider    = dateTimeProvider;
            _logger = logger;

            _clientConnectionOptions        = clientConnectionOptionsAccessor.Value ?? new ClientConnectionOptions();
            _clientConnectionManagerOptions = clientConnectionManagerOptionsAccessor.Value ?? new ClientConnectionManagerOptions();

            Timeout  = _clientConnectionOptions.Timeout <= TimeSpan.Zero ? ClientConnectionOptions.DefaultTimeout : _clientConnectionOptions.Timeout;
            BasePath = new CoordinationEntryPath(string.IsNullOrEmpty(_clientConnectionManagerOptions.BasePath) ? ClientConnectionManagerOptions.DefaultBasePath : _clientConnectionManagerOptions.BasePath);
            GarbageCollectionDelayMax = _clientConnectionManagerOptions.GarbageCollectionDelayMax <= TimeSpan.Zero ? ClientConnectionManagerOptions.DefaultGarbageCollectionDelayMax : _clientConnectionManagerOptions.GarbageCollectionDelayMax;


            _garbageCollectionProcess = new AsyncProcess(GarbageCollection, start: true);
        }
コード例 #6
0
 public Task <int> DeleteAsync(string path, int version = 0, bool recursive = false, CancellationToken cancellation = default)
 {
     return(_coordinationManager.DeleteAsync(CoordinationEntryPath.FromEscapedPath(path.AsMemory()), version, recursive, cancellation).AsTask());
 }
コード例 #7
0
 public Task <int> SetValueAsync(string path, byte[] value, int version = 0, CancellationToken cancellation = default)
 {
     return(_coordinationManager.SetValueAsync(CoordinationEntryPath.FromEscapedPath(path.AsMemory()), value, version, cancellation).AsTask());
 }
コード例 #8
0
        public async ValueTask <int> DeleteAsync(CoordinationEntryPath path, int version = 0, bool recursive = false, CancellationToken cancellation = default)
        {
            var proxy = await GetProxyAsync(cancellation);

            return(await proxy.ExecuteAsync(p => p.DeleteAsync(path.EscapedPath.ConvertToString(), version, recursive, cancellation)));
        }
コード例 #9
0
        public async ValueTask <int> SetValueAsync(CoordinationEntryPath path, ReadOnlyMemory <byte> value, int version = 0, CancellationToken cancellation = default)
        {
            var proxy = await GetProxyAsync(cancellation);

            return(await proxy.ExecuteAsync(p => p.SetValueAsync(path.EscapedPath.ConvertToString(), value.ToArray(), version, cancellation)));
        }