MCPcopy
hub / github.com/nats-io/nats.go / ExampleCustomDialer

Function ExampleCustomDialer

example_test.go:61–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59}
60
61func ExampleCustomDialer() {
62 // Given the following CustomDialer implementation:
63 //
64 // type skipTLSDialer struct {
65 // dialer *net.Dialer
66 // skipTLS bool
67 // }
68 //
69 // func (sd *skipTLSDialer) Dial(network, address string) (net.Conn, error) {
70 // return sd.dialer.Dial(network, address)
71 // }
72 //
73 // func (sd *skipTLSDialer) SkipTLSHandshake() bool {
74 // return true
75 // }
76 //
77 sd := &skipTLSDialer{dialer: &net.Dialer{Timeout: 2 * time.Second}, skipTLS: true}
78 nc, _ := nats.Connect("demo.nats.io", nats.SetCustomDialer(sd))
79 defer nc.Close()
80}
81
82// This Example shows an asynchronous subscriber.
83func ExampleConn_Subscribe() {

Callers

nothing calls this directly

Calls 2

ConnectMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected