Exemple #1
0
 public static async Task DropSpaceAsync(
     this ITarantoolClient tarantoolClient,
     string spaceName,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     await tarantoolClient.EvalAsync($"box.space.{spaceName}:drop()", cancellationToken).ConfigureAwait(false);
 }
Exemple #2
0
 /// <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;
     }
 }
Exemple #3
0
 /// <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;
     }
 }