// ReadTimeout read a msg  with a timeout duration
962200
func (s *clientIOSession) ReadTimeout(timeout time.Duration) (interface{}, error) {
	for {
		doRead, msg, err := s.doPreRead()
		if err != nil {
			return nil, err
		}
		if !doRead {
			return msg, nil
		}

		var complete bool
		for {
			if s.in.Readable() > 0 {
				complete, msg, err = s.svr.opts.decoder.Decode(s.in)

				if !complete && err == nil {
					complete, msg, err = s.readFromConn(timeout)
				}
			} else {
				complete, msg, err = s.readFromConn(timeout)
			}

			if nil != err {
				s.in.Clear()
				return nil, err
			}

			if complete {
				break
			}
		}

		if s.in.Readable() == 0 {
			s.in.Clear()
		}

		returnRead, readedMsg, err := s.doPostRead(msg)
		if err != nil {
			return nil, err
		}

		if returnRead {
			return readedMsg, err
		}
	}
}
652651
func (s *CatIndicesService) MasterTimeout(masterTimeout string) *CatIndicesService {
	s.masterTimeout = masterTimeout
	return s
}
964679
func Timeout(t time.Duration) metaOp {
	return func(c *Client) {
		c.http.Timeout = t
	}
}
410833
func (s *IndicesCreateService) Timeout(timeout string) *IndicesCreateService {
	s.timeout = timeout
	return s
}
939387
func (s *IndicesDeleteService) Timeout(timeout string) *IndicesDeleteService {
	s.timeout = timeout
	return s
}
1014928
func (s *IndicesFreezeService) Timeout(timeout string) *IndicesFreezeService {
	s.timeout = timeout
	return s
}
1134161
func (s *OpenIndexService) MasterTimeout(masterTimeout string) *OpenIndexService {
	s.masterTimeout = masterTimeout
	return s
}
167641
func (s *SnapshotCreateRepositoryService) Timeout(timeout string) *SnapshotCreateRepositoryService {
	s.timeout = timeout
	return s
}
784289
func (c *Conn) DoWithTimeout(readTimeout time.Duration, cmd string, args ...interface{}) (interface{}, error) {
	return c.Do(cmd, args...)
}
192925
func (s *IndicesCloseService) Timeout(timeout string) *IndicesCloseService {
	s.timeout = timeout
	return s
}
604641
func (c *Websocket) WithReadTimeout(timeout time.Duration) *Websocket {
	c.readTimeout = timeout
	return c
}
361477
func (s *CloseIndexService) Timeout(timeout string) *CloseIndexService {
	s.timeout = timeout
	return s
}
374504
func (c *Client) ReceiveMsgTimeout(timeout time.Duration) (*pstypes.WebSocketMessage, error) {
	_ = c.SetReadDeadline(time.Now().Add(timeout))
	msg := new(pstypes.WebSocketMessage)
	if err := websocket.JSON.Receive(c.Conn, &msg); err != nil {
		return nil, err
	}
	return msg, nil
}
757618
func (c *MockCommunicator) Timeout() time.Duration {
	if c.ConnTimeout != 0 {
		return c.ConnTimeout
	}
	return time.Duration(5 * time.Second)
}
1325493
func WithReadTimeout(timeout string) ClientOptionFunc {
	return func(c *Client) error {
		if timeout == "" {
			c.readTimeout = DefaultTimeout
			return nil
		}

		t, err := time.ParseDuration(timeout)
		if err != nil {
			return client.InvalidTimeoutError{Timeout: timeout}
		}
		c.readTimeout = t
		return nil
	}
}
1331711
func Timeout(timeout time.Duration) Option {
	return func(g *Generator) {
		g.Timeout = timeout
	}
}
1294698
func (s *IndexService) Timeout(timeout string) *IndexService {
	s.timeout = timeout
	return s
}