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, #delete, #disconnect, #each, #initialize, #key?, #rbclidata, #refresh, #set_rbclidata, #to_h, #to_s
Instance Method Details
#create_state ⇒ Object
57
58
59
60
61
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 57
def create_state
make_dynamo_call do
@dynamodb.create_table
end
end
|
#error(text) ⇒ Object
83
84
85
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 83
def error text
raise RemoteStateError.new "Error accessing remote state: #{text}"
end
|
#load_state ⇒ Object
63
64
65
66
67
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 63
def load_state
make_dynamo_call do
@data = @dynamodb.get_object.deep_symbolize!
end
end
|
#lock ⇒ Object
75
76
77
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 75
def lock
@dynamodb.lock_or_wait if @locking
end
|
#save_state ⇒ Object
69
70
71
72
73
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 69
def save_state
make_dynamo_call do
@dynamodb.save_object @data
end
end
|
#state_exists? ⇒ Boolean
52
53
54
55
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 52
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
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 40
def state_subsystem_init
@locking = Rbcli::ConfigurateStorage::data[:remotestate_init_params][:locking]
dynamodb_table = Rbcli::ConfigurateStorage::data[:remotestate_init_params][:dynamodb_table]
region = Rbcli::ConfigurateStorage::data[:remotestate_init_params][:region]
Rbcli::State::RemoteConnectors::DynamoDB.save_defaults
@dynamodb = Rbcli::State::RemoteConnectors::DynamoDB.new dynamodb_table, region, Rbcli::config[:aws_access_key_id], Rbcli::config[:aws_secret_access_key], locking: Rbcli::ConfigurateStorage::data[:remotestate_init_params][:locking]
end
|
#unlock ⇒ Object
79
80
81
|
# File 'lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb', line 79
def unlock
@dynamodb.unlock if @locking
end
|