Class: Arcp::Credentials::InMemoryStore

Inherits:
CredentialStore show all
Defined in:
lib/arcp/credential_provisioner.rb

Instance Method Summary collapse

Constructor Details

#initializeInMemoryStore

Returns a new instance of InMemoryStore.



102
103
104
105
106
# File 'lib/arcp/credential_provisioner.rb', line 102

def initialize
  super
  @by_job = Hash.new { |hash, key| hash[key] = [] }
  @mutex = Mutex.new
end

Instance Method Details

#all_outstandingObject



125
126
127
128
129
# File 'lib/arcp/credential_provisioner.rb', line 125

def all_outstanding
  @mutex.synchronize do
    @by_job.transform_values { |ids| ids.dup.freeze }.freeze
  end
end

#forget(job_id:, credential_id:) ⇒ Object



113
114
115
116
117
118
119
# File 'lib/arcp/credential_provisioner.rb', line 113

def forget(job_id:, credential_id:)
  @mutex.synchronize do
    @by_job[job_id].delete(credential_id)
    @by_job.delete(job_id) if @by_job[job_id].empty?
  end
  nil
end

#outstanding(job_id:) ⇒ Object



121
122
123
# File 'lib/arcp/credential_provisioner.rb', line 121

def outstanding(job_id:)
  @mutex.synchronize { @by_job[job_id].dup.freeze }
end

#record(job_id:, credential_id:) ⇒ Object



108
109
110
111
# File 'lib/arcp/credential_provisioner.rb', line 108

def record(job_id:, credential_id:)
  @mutex.synchronize { @by_job[job_id] |= [credential_id] }
  nil
end