public override IScope this[string scopeName]
        {
            get
            {
                Logger.LogDebug("Fetching scope {scopeName}", Redactor.UserData(scopeName));

                return(Scopes.GetOrAdd(scopeName, s => _scopeFactory.CreateScope(s, this)));
            }
        }
Ejemplo n.º 2
0
        public void When_Full_Redaction_Redact_Everything()
        {
            var ctx = new ClusterContext();

            ctx.ClusterOptions.RedactionLevel = RedactionLevel.Full;
            var redactor = new Redactor(ctx);

            Assert.Equal("<ud>user</ud>", redactor.UserData("user").ToString());
            Assert.Equal("<md>meta</md>", redactor.MetaData("meta").ToString());
            Assert.Equal("<sd>system</sd>", redactor.SystemData("system").ToString());
        }
Ejemplo n.º 3
0
        public void When_User_Redaction_Redact_Partial()
        {
            var ctx = new ClusterContext();

            ctx.ClusterOptions.RedactionLevel = RedactionLevel.Partial;
            var redactor = new Redactor(ctx);

            Assert.Equal("<ud>user</ud>", redactor.UserData("user").ToString());
            Assert.Equal("meta", redactor.MetaData("meta").ToString());
            Assert.Equal("system", redactor.SystemData("system").ToString());
        }
Ejemplo n.º 4
0
        public void When_Redaction_Disabled_No_Redaction_Occurs()
        {
            var ctx = new ClusterContext();

            ctx.ClusterOptions.RedactionLevel = RedactionLevel.None;
            var redactor = new Redactor(ctx);

            Assert.Equal("1", redactor.UserData("1").ToString());
            Assert.Null(redactor.MetaData(null));
            Assert.Equal("system", redactor.SystemData("system").ToString());
        }
Ejemplo n.º 5
0
        public void When_Redaction_Disabled_No_Redaction_Occurs()
        {
            var options = new ClusterOptions
            {
                RedactionLevel = RedactionLevel.None
            };

            var redactor = new Redactor(options);

            Assert.Equal("1", redactor.UserData("1").ToString());
            Assert.Null(redactor.MetaData(null));
            Assert.Equal("system", redactor.SystemData("system").ToString());
        }
Ejemplo n.º 6
0
        public void When_User_Redaction_Redact_Partial()
        {
            var options = new ClusterOptions
            {
                RedactionLevel = RedactionLevel.Partial
            };

            var redactor = new Redactor(options);

            Assert.Equal("<ud>user</ud>", redactor.UserData("user").ToString());
            Assert.Equal("meta", redactor.MetaData("meta").ToString());
            Assert.Equal("system", redactor.SystemData("system").ToString());
        }
        public override IScope this[string scopeName]
        {
            get
            {
                Logger.LogDebug("Fetching scope {scopeName}", Redactor.UserData(scopeName));

                if (Scopes.TryGetValue(scopeName, out var scope))
                {
                    return(scope);
                }

                throw new ScopeNotFoundException(scopeName);
            }
        }
 protected override void CreateBackingStore()
 {
     if (BackingStoreChecked)
     {
         return;
     }
     try
     {
         Collection.InsertAsync(Key, new HashSet <TValue>()).GetAwaiter().GetResult();
         BackingStoreChecked = true;
     }
     catch (DocumentExistsException e)
     {
         //ignore - the doc already exists for this collection
         Logger.LogTrace(e, "The PersistentList backing document already exists for ID {key}. Not an error.",
                         Redactor?.UserData(Key));
     }
 }
Ejemplo n.º 9
0
        protected override async ValueTask CreateBackingStoreAsync()
        {
            if (BackingStoreChecked)
            {
                return;
            }
            try
            {
                // Typecast to ISet<TValue> to provide a consistent type which can be registered
                // by the consumer on their JsonSerializerContext
                await Collection.InsertAsync(Key, (ISet <TValue>) new HashSet <TValue>()).ConfigureAwait(false);

                BackingStoreChecked = true;
            }
            catch (DocumentExistsException e)
            {
                //ignore - the doc already exists for this collection
                Logger?.LogTrace(e, "The PersistentList backing document already exists for ID {key}. Not an error.",
                                 Redactor?.UserData(Key));
            }
        }
Ejemplo n.º 10
0
        internal override async Task BootstrapAsync(IClusterNode node)
        {
            try
            {
                Logger.LogInformation("Bootstrapping: server negotiation started for {name}.", Redactor.UserData(Name));
                if (Context.ClusterOptions.HasNetworkResolution)
                {
                    //Network resolution determined at the GCCCP level
#pragma warning disable CS8602 // Dereference of a possibly null reference.
                    CurrentConfig.NetworkResolution = Context.ClusterOptions.EffectiveNetworkResolution;
#pragma warning restore CS8602 // Dereference of a possibly null reference.
                }
                else
                {
                    //A non-GCCCP cluster
#pragma warning disable CS8602 // Dereference of a possibly null reference.
                    CurrentConfig.SetEffectiveNetworkResolution(Context.ClusterOptions);
#pragma warning restore CS8602 // Dereference of a possibly null reference.
                }
                if (SupportsCollections)
                {
                    Manifest = await node.GetManifest().ConfigureAwait(false);
                }

                await node.HelloHello().ConfigureAwait(false);

                KeyMapper = _vBucketKeyMapperFactory.Create(CurrentConfig);

                Nodes.Add(node);
                await Context.ProcessClusterMapAsync(this, CurrentConfig).ConfigureAwait(false);

                var nodes = Context.GetNodes(Name);

                //update the local nodes collection
                lock (Nodes)
                {
                    foreach (var clusterNode in nodes)
                    {
                        if (!Nodes.TryGet(clusterNode.EndPoint, out _))
                        {
                            Nodes.Add(clusterNode);
                        }
                    }
                }

                ClearErrors();

                Logger.LogInformation("Bootstrapping: server negotiation completed for {name}.", Redactor.UserData(Name));
            }
            catch (Exception e)
            {
                if (e is CouchbaseException ce)
                {
                    if (ce.Context is KeyValueErrorContext {
                        Status : ResponseStatus.NotSupported
                    })