public static async Task DropSpaceAsync( this ITarantoolClient tarantoolClient, string spaceName, CancellationToken cancellationToken = default(CancellationToken)) { await tarantoolClient.EvalAsync($"box.space.{spaceName}:drop()", cancellationToken).ConfigureAwait(false); }
/// <exception cref="ArgumentException">parts is null or empty.</exception> /// <exception cref="IndexAlreadyExistsException"></exception> /// <exception cref="TarantoolResponseException"></exception> public static async Task CreateIndexAsync( this ITarantoolClient tarantoolClient, string spaceName, string indexName, IndexType indexType, bool unique, CancellationToken cancellationToken, params IndexPart[] parts) { try { if (parts == null || !parts.Any()) { throw new ArgumentException(nameof(parts)); } var partsString = string.Join(",", parts.Select(x => $"{x.FieldNumber + 1}, '{x.Type.ToString()}'")); await tarantoolClient.EvalAsync( $"box.space.{spaceName}:create_index('{indexName}', {{type = '{indexType}', unique = {unique.ToString().ToLower()}, parts = {{{partsString}}}}})", cancellationToken) .ConfigureAwait(false); } catch (TarantoolResponseException ex) { if (ex.Message.StartsWith("Index") && ex.Message.EndsWith("already exists")) { throw new IndexAlreadyExistsException(ex.Message, ex); } throw; } }
public static Task <MessagePackObject> EvalAsync( this ITarantoolClient tarantoolClient, string expression, params object[] args) { return(tarantoolClient.RequestAsync(new EvalRequest { Expression = expression, Args = args })); }
/// <exception cref="ArgumentException">parts is null or empty.</exception> /// <exception cref="IndexAlreadyExistsException"></exception> /// <exception cref="TarantoolResponseException"></exception> public static Task CreateIndexAsync( this ITarantoolClient tarantoolClient, string spaceName, string indexName, IndexType indexType, params IndexPart[] parts) { return(tarantoolClient.CreateIndexAsync(spaceName, indexName, indexType, CancellationToken.None, parts)); }
/// <exception cref="TarantoolResponseException"></exception> public static async Task CreateSpaceIfNotExistsAsync( this ITarantoolClient tarantoolClient, string spaceName, CancellationToken cancellationToken = default(CancellationToken)) { try { await tarantoolClient.CreateSpaceAsync(spaceName, cancellationToken).ConfigureAwait(false); } catch (SpaceAlreadyExistsException) { } }
/// <exception cref="TarantoolResponseException"></exception> public static async Task CreateIndexIfNotExistsAsync( this ITarantoolClient tarantoolClient, string spaceName, string indexName, IndexType indexType, params IndexPart[] parts) { try { await tarantoolClient.CreateIndexAsync(spaceName, indexName, indexType, parts).ConfigureAwait(false); } catch (IndexAlreadyExistsException) { } }
/// <exception cref="SpaceAlreadyExistsException"></exception> /// <exception cref="TarantoolResponseException"></exception> public static async Task CreateSpaceAsync( this ITarantoolClient tarantoolClient, string spaceName, CancellationToken cancellationToken = default(CancellationToken)) { try { await tarantoolClient.EvalAsync($"box.schema.create_space('{spaceName}')", cancellationToken) .ConfigureAwait(false); } catch (TarantoolResponseException ex) { if (ex.Message.StartsWith("Space") && ex.Message.EndsWith("already exists")) { throw new SpaceAlreadyExistsException(ex.Message, ex); } throw; } }
public TarantoolSpace(ITarantoolClient tarantoolClient, string spaceName) { TarantoolClient = tarantoolClient; _spaceName = spaceName; }
public TarantoolSpace(ITarantoolClient tarantoolClient, uint spaceId) { TarantoolClient = tarantoolClient; SpaceId = spaceId; }
/// <summary>Initializes a new instance of the <see cref="TarantoolIndex{T, TKey}" /> class by index name.</summary> /// <param name="tarantoolClient">The tarantool client.</param> /// <param name="space">The space.</param> /// <param name="indexName">The index name.</param> public TarantoolIndex(ITarantoolClient tarantoolClient, ITarantoolSpace <T> space, string indexName) { TarantoolClient = tarantoolClient; Space = space; _indexName = indexName; }
/// <summary>Initializes a new instance of the <see cref="TarantoolIndex{T, TKey}" /> class by index id.</summary> /// <param name="tarantoolClient">The tarantool client.</param> /// <param name="space">The space.</param> /// <param name="indexId">The index id.</param> public TarantoolIndex(ITarantoolClient tarantoolClient, ITarantoolSpace <T> space, uint indexId) { TarantoolClient = tarantoolClient; Space = space; IndexId = indexId; }