Disable sniffing and pinging per requestedit

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())
    .SniffingConnectionPool()
    .Settings(s => s.SniffOnStartup()) 
);

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()) 
    {
        { PingSuccess, 9200 }, 
        { HealthyResponse, 9200 }
    },
    new ClientCall()
    {
        { SniffOnStartup }, 
        { SniffSuccess, 9200 },
        { PingSuccess, 9200 },
        { HealthyResponse, 9200 }
    },
    new ClientCall()
    {
        { PingSuccess, 9201 }, 
        { HealthyResponse, 9201 }
    }
);

disable sniffing

first call is a successful ping

sniff on startup call happens here, on the second call

No sniff on startup again

Now, let’s disable pinging 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.DisablePing()) 
    {
        { SniffOnStartup },
        { SniffSuccess, 9200 }, 
        { HealthyResponse, 9200 }
    }
);

disable ping

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()) 
    {
        { HealthyResponse, 9200 } 
    }
);

disable ping and sniff

no ping or sniff before the call