示例#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);
 }
示例#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;
     }
 }
示例#3
0
 public static Task <MessagePackObject> EvalAsync(
     this ITarantoolClient tarantoolClient,
     string expression,
     params object[] args)
 {
     return(tarantoolClient.RequestAsync(new EvalRequest {
         Expression = expression, Args = args
     }));
 }
示例#4
0
 /// <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));
 }
示例#5
0
 /// <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)
     {
     }
 }
示例#7
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;
     }
 }
 public TarantoolSpace(ITarantoolClient tarantoolClient, string spaceName)
 {
     TarantoolClient = tarantoolClient;
     _spaceName      = spaceName;
 }
 public TarantoolSpace(ITarantoolClient tarantoolClient, uint spaceId)
 {
     TarantoolClient = tarantoolClient;
     SpaceId         = spaceId;
 }
示例#10
0
 /// <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;
 }
示例#11
0
 /// <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;
 }