MCPcopy
hub / github.com/micro/go-micro / Init

Method Init

client/rpc_client.go:350–379  ·  view source on GitHub ↗
(opts ...Option)

Source from the content-addressed store, hash-verified

348}
349
350func (r *rpcClient) Init(opts ...Option) error {
351 r.mu.Lock()
352 defer r.mu.Unlock()
353
354 size := r.opts.PoolSize
355 ttl := r.opts.PoolTTL
356 tr := r.opts.Transport
357
358 for _, o := range opts {
359 o(&r.opts)
360 }
361
362 // update pool configuration if the options changed
363 if size != r.opts.PoolSize || ttl != r.opts.PoolTTL || tr != r.opts.Transport {
364 // close existing pool
365 if err := r.pool.Close(); err != nil {
366 return errors.Wrap(err, "failed to close pool")
367 }
368
369 // create new pool
370 r.pool = pool.NewPool(
371 pool.Size(r.opts.PoolSize),
372 pool.TTL(r.opts.PoolTTL),
373 pool.Transport(r.opts.Transport),
374 pool.CloseTimeout(r.opts.PoolCloseTimeout),
375 )
376 }
377
378 return nil
379}
380
381// Options retrives the options.
382func (r *rpcClient) Options() Options {

Callers

nothing calls this directly

Calls 6

NewPoolFunction · 0.92
SizeFunction · 0.92
TTLFunction · 0.92
TransportFunction · 0.92
CloseTimeoutFunction · 0.92
CloseMethod · 0.65

Tested by

no test coverage detected