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)); }
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)); }
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); }
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); }
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); }
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()); }
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()); }
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))); }
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))); }