Class: ClusterFsck::Writer
- Inherits:
-
Object
- Object
- ClusterFsck::Writer
- Includes:
- S3Methods
- Defined in:
- lib/clusterfsck/writer.rb
Instance Attribute Summary collapse
-
#cluster_fsck_env ⇒ Object
readonly
Returns the value of attribute cluster_fsck_env.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key, opts = {}) ⇒ Writer
constructor
A new instance of Writer.
- #raise_unless_version_count_is_good(version_count) ⇒ Object
-
#set(val, version_count = nil) ⇒ Object
todo, thread safety and process safety please.
- #stored_object ⇒ Object
Methods included from S3Methods
#all_environments, #all_files, #bucket, credentials, #credentials, #full_s3_path, #s3, s3, #s3_object
Constructor Details
#initialize(key, opts = {}) ⇒ Writer
Returns a new instance of Writer.
6 7 8 9 |
# File 'lib/clusterfsck/writer.rb', line 6 def initialize(key, opts = {}) @key = key @cluster_fsck_env = opts[:cluster_fsck_env] || ClusterFsck.cluster_fsck_env end |
Instance Attribute Details
#cluster_fsck_env ⇒ Object (readonly)
Returns the value of attribute cluster_fsck_env.
5 6 7 |
# File 'lib/clusterfsck/writer.rb', line 5 def cluster_fsck_env @cluster_fsck_env end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/clusterfsck/writer.rb', line 5 def key @key end |
Instance Method Details
#raise_unless_version_count_is_good(version_count) ⇒ Object
18 19 20 21 22 |
# File 'lib/clusterfsck/writer.rb', line 18 def raise_unless_version_count_is_good(version_count) if version_count and stored_object.versions.count > version_count raise ConflictError, "File #{key} changed underneath you, version_count expected to be #{version_count} but was #{stored_object.versions.count}" end end |
#set(val, version_count = nil) ⇒ Object
todo, thread safety and process safety please
12 13 14 15 16 |
# File 'lib/clusterfsck/writer.rb', line 12 def set(val, version_count = nil) raise_unless_version_count_is_good(version_count) stored_object.write(val.to_yaml) raise_unless_version_count_is_good(version_count + 1) if version_count end |
#stored_object ⇒ Object
24 25 26 |
# File 'lib/clusterfsck/writer.rb', line 24 def stored_object @stored_object ||= s3_object(key) end |