Module: Riak::Client::FeatureDetection

Included in:
ProtobuffsBackend, SecondaryIndex
Defined in:
lib/riak/client/feature_detection.rb

Overview

Methods that can be used to determine whether certain features are supported by the Riak node to which the client backend is connected.

Backends must implement the “get_server_version” method, returning a string representing the Riak node’s version. This is implemented on HTTP using the stats resource, and on Protocol Buffers using the RpbGetServerInfoReq message.

Constant Summary collapse

VERSION =

Constants representing Riak versions

{
  1 => Gem::Version.new("1.0.0"),
  1.1 => Gem::Version.new("1.1.0"),
  1.2 => Gem::Version.new("1.2.0"),
  1.3 => Gem::Version.new("1.3.0"),
  1.4 => Gem::Version.new("1.4.0")
}.freeze

Instance Method Summary collapse

Instance Method Details

#get_server_versionString

This method is abstract.

Returns the version of the Riak node.

Returns:

  • (String)

    the version of the Riak node

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/riak/client/feature_detection.rb', line 37

def get_server_version
  raise NotImplementedError
end

#http_props_clearable?true, false

Returns whether bucket properties can be cleared (reset to defaults) over HTTP.

Returns:

  • (true, false)

    whether bucket properties can be cleared (reset to defaults) over HTTP



92
93
94
# File 'lib/riak/client/feature_detection.rb', line 92

def http_props_clearable?
  at_least? VERSION[1.3]
end

#index_pagination?true, false

Returns whether secondary indexes support pagination.

Returns:

  • (true, false)

    whether secondary indexes support pagination



98
99
100
# File 'lib/riak/client/feature_detection.rb', line 98

def index_pagination?
  at_least? VERSION[1.4]
end

#index_return_terms?true, false

Whether secondary indexes support return_terms

Returns:

  • (true, false)

    whether secondary indexes support return_terms



104
105
106
# File 'lib/riak/client/feature_detection.rb', line 104

def index_return_terms?
  at_least? VERSION[1.4]
end

#index_streaming?true, false

Returns whether secondary indexes support streaming.

Returns:

  • (true, false)

    whether secondary indexes support streaming



110
111
112
# File 'lib/riak/client/feature_detection.rb', line 110

def index_streaming?
  at_least? VERSION[1.4]
end

#key_object_bucket_timeouts?true, false

Returns whether timeouts are accepted for object CRUD, key listing, and bucket listing.

Returns:

  • (true, false)

    whether timeouts are accepted for object CRUD, key listing, and bucket listing



116
117
118
# File 'lib/riak/client/feature_detection.rb', line 116

def key_object_bucket_timeouts?
  at_least? VERSION[1.4]
end

#mapred_phaseless?true, false

Returns whether MapReduce requests can be submitted without phases.

Returns:

  • (true, false)

    whether MapReduce requests can be submitted without phases.



49
50
51
# File 'lib/riak/client/feature_detection.rb', line 49

def mapred_phaseless?
  at_least? VERSION[1.1]
end

#pb_conditionals?true, false

Returns whether conditional fetch/store semantics are supported over Protocol Buffers.

Returns:

  • (true, false)

    whether conditional fetch/store semantics are supported over Protocol Buffers



67
68
69
# File 'lib/riak/client/feature_detection.rb', line 67

def pb_conditionals?
  at_least? VERSION[1]
end

#pb_head?true, false

Returns whether partial-fetches (vclock and metadata only) are supported over Protocol Buffers.

Returns:

  • (true, false)

    whether partial-fetches (vclock and metadata only) are supported over Protocol Buffers



86
87
88
# File 'lib/riak/client/feature_detection.rb', line 86

def pb_head?
  at_least? VERSION[1]
end

#pb_indexes?true, false

Returns whether secondary index queries are supported over Protocol Buffers.

Returns:

  • (true, false)

    whether secondary index queries are supported over Protocol Buffers



55
56
57
# File 'lib/riak/client/feature_detection.rb', line 55

def pb_indexes?
  at_least? VERSION[1.2]
end

#pb_search?true, false

Returns whether search queries are supported over Protocol Buffers.

Returns:

  • (true, false)

    whether search queries are supported over Protocol Buffers



61
62
63
# File 'lib/riak/client/feature_detection.rb', line 61

def pb_search?
  at_least? VERSION[1.2]
end

#quorum_controls?true, false

Returns whether additional quorums and FSM controls are available, e.g. primary quorums, basic_quorum, notfound_ok.

Returns:

  • (true, false)

    whether additional quorums and FSM controls are available, e.g. primary quorums, basic_quorum, notfound_ok



74
75
76
# File 'lib/riak/client/feature_detection.rb', line 74

def quorum_controls?
  at_least? VERSION[1]
end

#server_versionGem::Version

Returns the version of the Riak node to which this backend is connected.

Returns:

  • (Gem::Version)

    the version of the Riak node to which this backend is connected



43
44
45
# File 'lib/riak/client/feature_detection.rb', line 43

def server_version
  @server_version ||= Gem::Version.new(get_server_version.split("-").first)
end

#tombstone_vclocks?true, false

Returns whether “not found” responses might include vclocks.

Returns:

  • (true, false)

    whether “not found” responses might include vclocks



80
81
82
# File 'lib/riak/client/feature_detection.rb', line 80

def tombstone_vclocks?
  at_least? VERSION[1]
end