コード例 #1
0
 internal StreamConfiguration(JSONNode scNode)
 {
     RetentionPolicy   = ApiEnums.GetValueOrDefault(scNode[ApiConstants.Retention].Value, RetentionPolicy.Limits);
     StorageType       = ApiEnums.GetValueOrDefault(scNode[ApiConstants.Storage].Value, StorageType.File);
     DiscardPolicy     = ApiEnums.GetValueOrDefault(scNode[ApiConstants.Discard].Value, DiscardPolicy.Old);
     Name              = scNode[ApiConstants.Name].Value;
     Description       = scNode[ApiConstants.Description].Value;
     Subjects          = StringList(scNode, ApiConstants.Subjects);
     MaxConsumers      = scNode[ApiConstants.MaxConsumers].AsLong;
     MaxMsgs           = AsLongOrMinus1(scNode, ApiConstants.MaxMsgs);
     MaxMsgsPerSubject = AsLongOrMinus1(scNode, ApiConstants.MaxMsgsPerSubject);
     MaxBytes          = AsLongOrMinus1(scNode, ApiConstants.MaxBytes);
     MaxAge            = AsDuration(scNode, ApiConstants.MaxAge, Duration.Zero);
     MaxValueSize      = AsLongOrMinus1(scNode, ApiConstants.MaxMsgSize);
     Replicas          = scNode[ApiConstants.NumReplicas].AsInt;
     NoAck             = scNode[ApiConstants.NoAck].AsBool;
     TemplateOwner     = scNode[ApiConstants.TemplateOwner].Value;
     DuplicateWindow   = AsDuration(scNode, ApiConstants.DuplicateWindow, Duration.Zero);
     Placement         = Placement.OptionalInstance(scNode[ApiConstants.Placement]);
     Mirror            = Mirror.OptionalInstance(scNode[ApiConstants.Mirror]);
     Sources           = Source.OptionalListOf(scNode[ApiConstants.Sources]);
     Sealed            = scNode[ApiConstants.Sealed].AsBool;
     AllowRollup       = scNode[ApiConstants.AllowRollupHdrs].AsBool;
     DenyDelete        = scNode[ApiConstants.DenyDelete].AsBool;
     DenyPurge         = scNode[ApiConstants.DenyPurge].AsBool;
 }
コード例 #2
0
 public StreamConfigurationBuilder(StreamConfiguration sc)
 {
     if (sc == null)
     {
         return;
     }
     _name        = sc.Name;
     _description = sc.Description;
     WithSubjects(sc.Subjects); // handles null
     _retentionPolicy   = sc.RetentionPolicy;
     _maxConsumers      = sc.MaxConsumers;
     _maxMsgs           = sc.MaxMsgs;
     _maxMsgsPerSubject = sc.MaxMsgsPerSubject;
     _maxBytes          = sc.MaxBytes;
     _maxAge            = sc.MaxAge;
     _maxMsgSize        = sc.MaxValueSize;
     _storageType       = sc.StorageType;
     _replicas          = sc.Replicas;
     _noAck             = sc.NoAck;
     _templateOwner     = sc.TemplateOwner;
     _discardPolicy     = sc.DiscardPolicy;
     _duplicateWindow   = sc.DuplicateWindow;
     _placement         = sc.Placement;
     _mirror            = sc.Mirror;
     WithSources(sc.Sources);
     _sealed      = sc.Sealed;
     _allowRollup = sc.AllowRollup;
     _denyDelete  = sc.DenyDelete;
     _denyPurge   = sc.DenyPurge;
 }
コード例 #3
0
        internal override JSONNode ToJsonNode()
        {
            JSONArray sources = new JSONArray();

            if (Sources != null)
            {
                foreach (Source s in Sources)
                {
                    sources.Add(null, s.ToJsonNode());
                }
            }
            return(new JSONObject
            {
                [ApiConstants.Retention] = RetentionPolicy.GetString(),
                [ApiConstants.Storage] = StorageType.GetString(),
                [ApiConstants.Discard] = DiscardPolicy.GetString(),
                [ApiConstants.Name] = Name,
                [ApiConstants.Description] = Description,
                [ApiConstants.Subjects] = ToArray(Subjects),
                [ApiConstants.MaxConsumers] = MaxConsumers,
                [ApiConstants.MaxMsgs] = MaxMsgs,
                [ApiConstants.MaxMsgsPerSubject] = MaxMsgsPerSubject,
                [ApiConstants.MaxBytes] = MaxBytes,
                [ApiConstants.MaxAge] = MaxAge.Nanos,
                [ApiConstants.MaxMsgSize] = MaxValueSize,
                [ApiConstants.NumReplicas] = Replicas,
                [ApiConstants.NoAck] = NoAck,
                [ApiConstants.TemplateOwner] = TemplateOwner,
                [ApiConstants.DuplicateWindow] = DuplicateWindow.Nanos,
                [ApiConstants.Placement] = Placement?.ToJsonNode(),
                [ApiConstants.Mirror] = Mirror?.ToJsonNode(),
                [ApiConstants.Sources] = sources,
                // never write sealed
                [ApiConstants.AllowRollupHdrs] = AllowRollup,
                [ApiConstants.DenyDelete] = DenyDelete,
                [ApiConstants.DenyPurge] = DenyPurge
            });
        }
コード例 #4
0
ファイル: Mirror.cs プロジェクト: bojanskr/nats.net
 public bool Equals(Mirror other)
 {
     return(Name == other.Name && StartSeq == other.StartSeq && StartTime.Equals(other.StartTime) && FilterSubject == other.FilterSubject && Equals(External, other.External));
 }
コード例 #5
0
 /// <summary>
 /// Sets the mirror  object
 /// </summary>
 /// <param name="mirror">the mirror object</param>
 /// <returns>The StreamConfigurationBuilder</returns>
 public StreamConfigurationBuilder WithMirror(Mirror mirror)
 {
     _mirror = mirror;
     return(this);
 }