Skip to content

Latest commit

 

History

History
118 lines (99 loc) · 3.22 KB

disable-sniff-ping-per-request.asciidoc

File metadata and controls

118 lines (99 loc) · 3.22 KB

Disable sniffing and pinging per request

Even if you are using a sniffing connection pool thats set up to sniff on start/failure and pinging enabled, you can opt out of this behaviour on a per request basis.

In our first test we set up a cluster that pings and sniffs on startup but we disable the sniffing on our first request so we only see the ping and the response

Let’s set up the cluster and configure clients to always sniff on startup

var audit = new Auditor(() => VirtualClusterWith
    .Nodes(10)
    .ClientCalls(r => r.SucceedAlways())
    .Sniff(c=>c.SucceedAlways())
    .Ping(c=>c.SucceedAlways())
    .SniffingConnectionPool()
    .Settings(s => s.SniffOnStartup()) (1)
);
  1. sniff on startup

Now we disable sniffing on the request so even though it’s our first call, we do not want to sniff on startup.

Instead, the sniff on startup is deferred to the second call into the cluster that does not disable sniffing on a per request basis.

And after that no sniff on startup will happen again

audit = await audit.TraceCalls(
    new ClientCall(r => r.DisableSniffing()) (1)
    {
        { PingSuccess, 9200 }, (2)
        { HealthyResponse, 9200 }
    },
    new ClientCall()
    {
        { SniffOnStartup }, (3)
        { SniffSuccess, 9200 },
        { PingSuccess, 9200 },
        { HealthyResponse, 9200 }
    },
    new ClientCall()
    {
        { PingSuccess, 9201 }, (4)
        { HealthyResponse, 9201 }
    }
);
  1. disable sniffing

  2. first call is a successful ping

  3. sniff on startup call happens here, on the second call

  4. No sniff on startup again

Now, let’s disable pinging on the request

var audit = new Auditor(() => VirtualClusterWith
    .Nodes(10)
    .ClientCalls(r => r.SucceedAlways())
    .Sniff(c=>c.SucceedAlways())
    .SniffingConnectionPool()
    .Settings(s => s.SniffOnStartup())
);

audit = await audit.TraceCall(
    new ClientCall(r => r.DisablePing()) (1)
    {
        { SniffOnStartup },
        { SniffSuccess, 9200 }, (2)
        { HealthyResponse, 9200 }
    }
);
  1. disable ping

  2. No ping after sniffing

Finally, let’s demonstrate disabling both sniff and ping on the request

var audit = new Auditor(() => VirtualClusterWith
    .Nodes(10)
    .ClientCalls(r => r.SucceedAlways())
    .SniffingConnectionPool()
    .Settings(s => s.SniffOnStartup())
);

audit = await audit.TraceCall(
    new ClientCall(r=>r.DisableSniffing().DisablePing()) (1)
    {
        { HealthyResponse, 9200 } (2)
    }
);
  1. disable ping and sniff

  2. no ping or sniff before the call