示例#1
0
 internal KeyValue(IConnection connection, string bucketName, KeyValueOptions kvo)
 {
     BucketName    = Validator.ValidateKvBucketNameRequired(bucketName);
     StreamName    = KeyValueUtil.ToStreamName(BucketName);
     StreamSubject = KeyValueUtil.ToStreamSubject(BucketName);
     RawKeyPrefix  = KeyValueUtil.ToKeyPrefix(bucketName);
     if (kvo == null)
     {
         js              = new JetStream.JetStream(connection, null);
         jsm             = new JetStreamManagement(connection, null);
         PubSubKeyPrefix = RawKeyPrefix;
     }
     else
     {
         js  = new JetStream.JetStream(connection, kvo.JSOptions);
         jsm = new JetStreamManagement(connection, kvo.JSOptions);
         if (kvo.JSOptions.IsDefaultPrefix)
         {
             PubSubKeyPrefix = RawKeyPrefix;
         }
         else
         {
             PubSubKeyPrefix = kvo.JSOptions.Prefix + RawKeyPrefix;
         }
     }
 }
 /// <summary>
 /// Builds the KeyValueConfiguration
 /// </summary>
 /// <returns>the KeyValueConfiguration</returns>
 public KeyValueConfiguration Build()
 {
     _name = Validator.ValidateKvBucketNameRequired(_name);
     scBuilder.WithName(KeyValueUtil.ToStreamName(_name))
     .WithSubjects(KeyValueUtil.ToStreamSubject(_name))
     .WithAllowRollup(true)
     .WithDiscardPolicy(DiscardPolicy.New)
     .WithDenyDelete(true);
     return(new KeyValueConfiguration(scBuilder.Build()));
 }
示例#3
0
 public void Delete(string bucketName)
 {
     Validator.ValidateKvBucketNameRequired(bucketName);
     jsm.DeleteStream(KeyValueUtil.ToStreamName(bucketName));
 }
示例#4
0
 public KeyValueStatus GetBucketInfo(string bucketName)
 {
     Validator.ValidateKvBucketNameRequired(bucketName);
     return(new KeyValueStatus(jsm.GetStreamInfo(KeyValueUtil.ToStreamName(bucketName))));
 }
示例#5
0
 public KeyValueStatus Status()
 {
     return(new KeyValueStatus(jsm.GetStreamInfo(KeyValueUtil.ToStreamName(BucketName))));
 }