Module: GlobalUid::TestSupport

Defined in:
lib/global_uid/test_support.rb

Class Method Summary collapse

Class Method Details

.create_uid_tables(tables: [], uid_type: nil, start_id: nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/global_uid/test_support.rb', line 7

def create_uid_tables(tables: [], uid_type: nil, start_id: nil)
  return if GlobalUid.disabled?

  GlobalUid::Base.with_servers do |server|
    tables.each do |table|
      server.create_uid_table!(
        name: GlobalUid::Base.id_table_from_name(table),
        uid_type: uid_type,
        start_id: start_id
      )
    end
  end
end

.drop_uid_tables(tables: []) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/global_uid/test_support.rb', line 21

def drop_uid_tables(tables: [])
  return if GlobalUid.disabled?

  GlobalUid::Base.with_servers do |server|
    tables.each do |table|
      server.drop_uid_table!(
        name: GlobalUid::Base.id_table_from_name(table)
      )
    end
  end
end

.recreate_uid_tables(tables: [], uid_type: nil, start_id: nil) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/global_uid/test_support.rb', line 33

def recreate_uid_tables(tables: [], uid_type: nil, start_id: nil)
  return if GlobalUid.disabled?

  drop_uid_tables(tables: tables)
  create_uid_tables(tables: tables, uid_type: nil, start_id: start_id)

  # Reset the servers, clearing any allocations from memory
  GlobalUid::Base.disconnect!
end