Software /
code /
prosody
Comparison
util/hashring.lua @ 11208:96429946a742
util.hashring: Normalize indentation to tabs
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 15 Nov 2020 14:48:59 +0100 (2020-11-15) |
parent | 10005:409ff72c501c |
child | 12795:87424cbedc55 |
comparison
equal
deleted
inserted
replaced
11207:4e060ae8520b | 11208:96429946a742 |
---|---|
1 local function generate_ring(nodes, num_replicas, hash) | 1 local function generate_ring(nodes, num_replicas, hash) |
2 local new_ring = {}; | 2 local new_ring = {}; |
3 for _, node_name in ipairs(nodes) do | 3 for _, node_name in ipairs(nodes) do |
4 for replica = 1, num_replicas do | 4 for replica = 1, num_replicas do |
5 local replica_hash = hash(node_name..":"..replica); | 5 local replica_hash = hash(node_name..":"..replica); |
6 new_ring[replica_hash] = node_name; | 6 new_ring[replica_hash] = node_name; |
7 table.insert(new_ring, replica_hash); | 7 table.insert(new_ring, replica_hash); |
8 end | 8 end |
9 end | 9 end |
10 table.sort(new_ring); | 10 table.sort(new_ring); |
11 return new_ring; | 11 return new_ring; |
12 end | 12 end |
13 | 13 |
14 local hashring_methods = {}; | 14 local hashring_methods = {}; |
15 local hashring_mt = { | 15 local hashring_mt = { |