Class: Rbcli::State::DynamoDBStorage
- Inherits:
-
StateStorage
show all
- Defined in:
- lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb
Defined Under Namespace
Classes: RemoteStateError
Instance Method Summary
collapse
#[], #[]=, #clear, #commit, #delete, #disconnect, #each, #initialize, #key?, #rbclidata, #refresh, #set_rbclidata, #to_h, #to_s
Instance Method Details
#create_state ⇒ Object
77
78
79
80
81
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 77
def create_state
make_dynamo_call do
@dynamodb.create_table
end
end
|
#error(text) ⇒ Object
103
104
105
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 103
def error text
raise RemoteStateError.new "Error accessing remote state: #{text}"
end
|
#load_state ⇒ Object
83
84
85
86
87
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 83
def load_state
make_dynamo_call do
@data = @dynamodb.get_object.deep_symbolize!
end
end
|
#lock ⇒ Object
95
96
97
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 95
def lock
@dynamodb.lock_or_wait if @locking
end
|
#save_state ⇒ Object
89
90
91
92
93
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 89
def save_state
make_dynamo_call do
@dynamodb.save_object @data
end
end
|
#state_exists? ⇒ Boolean
72
73
74
75
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 72
def state_exists?
return false unless make_dynamo_call { @dynamodb.table_exists? }
make_dynamo_call { @dynamodb.object_exists? }
end
|
#state_subsystem_init ⇒ Object
def initialize dynamodb_table, region, force_creation: false, halt_on_error: true
Rbcli::State::RemoteStorage::Connectors::DynamoDB.save_defaults
@dynamodb = Rbcli::State::RemoteStorage::Connectors::DynamoDB.new dynamodb_table, region, Rbcli::config[:aws_access_key_id], Rbcli::config[:aws_secret_access_key]
super dynamodb_table, force_creation: force_creation, halt_on_error: halt_on_error
end
#unlock ⇒ Object
99
100
101
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 99
def unlock
@dynamodb.unlock if @locking
end
|