Class: Couchbase::Protostellar::Timeouts Private

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/protostellar/timeouts.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_value_timeout: nil, key_value_durable_timeout: nil, view_timeout: nil, query_timeout: nil, analytics_timeout: nil, search_timeout: nil, management_timeout: nil) ⇒ Timeouts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Timeouts.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/couchbase/protostellar/timeouts.rb', line 30

def initialize(
  key_value_timeout: nil,
  key_value_durable_timeout: nil,
  view_timeout: nil,
  query_timeout: nil,
  analytics_timeout: nil,
  search_timeout: nil,
  management_timeout: nil
)
  @key_value_durable_timeout = key_value_durable_timeout || TimeoutDefaults::KEY_VALUE_DURABLE
  @key_value_timeout = key_value_timeout || TimeoutDefaults::KEY_VALUE
  @view_timeout = view_timeout || TimeoutDefaults::VIEW
  @query_timeout = query_timeout || TimeoutDefaults::QUERY
  @analytics_timeout = analytics_timeout || TimeoutDefaults::ANALYTICS
  @search_timeout = search_timeout || TimeoutDefaults::SEARCH
  @management_timeout = management_timeout || TimeoutDefaults::MANAGEMENT
end

Instance Attribute Details

#analytics_timeoutObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
# File 'lib/couchbase/protostellar/timeouts.rb', line 26

def analytics_timeout
  @analytics_timeout
end

#key_value_timeoutObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
# File 'lib/couchbase/protostellar/timeouts.rb', line 23

def key_value_timeout
  @key_value_timeout
end

#management_timeoutObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/couchbase/protostellar/timeouts.rb', line 28

def management_timeout
  @management_timeout
end

#query_timeoutObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
# File 'lib/couchbase/protostellar/timeouts.rb', line 25

def query_timeout
  @query_timeout
end

#search_timeoutObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/couchbase/protostellar/timeouts.rb', line 27

def search_timeout
  @search_timeout
end

#view_timeoutObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/couchbase/protostellar/timeouts.rb', line 24

def view_timeout
  @view_timeout
end

Class Method Details

.from_cluster_options(options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



71
72
73
74
75
76
77
78
79
80
# File 'lib/couchbase/protostellar/timeouts.rb', line 71

def self.from_cluster_options(options)
  Timeouts.new(
    key_value_timeout: options.key_value_timeout,
    view_timeout: options.view_timeout,
    query_timeout: options.query_timeout,
    analytics_timeout: options.analytics_timeout,
    search_timeout: options.search_timeout,
    management_timeout: options.management_timeout
  )
end

Instance Method Details

#timeout_for_request(request) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/couchbase/protostellar/timeouts.rb', line 48

def timeout_for_request(request)
  case request.service
  when :analytics
    @analytics_timeout
  when :kv
    if request.proto_request.respond_to?(:durability_level) && request.proto_request.has_durability_level?
      @key_value_durable_timeout
    else
      @key_value_timeout
    end
  when :query
    @query_timeout
  when :search
    @search_timeout
  when :view
    @view_timeout
  when :bucket_admin, :collection_admin, :query_admin, :search_admin
    @management_timeout
  else
    raise Couchbase::Error::CouchbaseError, "Service #{service} not recognised"
  end
end