this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Encode config values with Keyset

+8 -13
+7 -2
lib/cluster_config.ex
··· 1 1 defmodule Hobbes.ClusterConfig do 2 2 alias Hobbes.ClusterConfig 3 + alias Hobbes.Encoding.Keyset 3 4 4 5 import Hobbes.Utils 5 6 6 7 @type t :: %__MODULE__{ 8 + num_replicas: pos_integer, 7 9 num_begin_buffers: pos_integer, 8 10 num_commit_buffers: pos_integer, 9 11 num_tlog_teams: pos_integer, 10 12 num_storage_teams: pos_integer, 13 + initial_shards: [binary], 11 14 } 12 15 @defaults [ 16 + num_replicas: 3, 13 17 num_begin_buffers: 1, 14 18 num_commit_buffers: 3, 15 19 num_tlog_teams: 1, 16 20 num_storage_teams: 2, 21 + initial_shards: [""], 17 22 ] 18 23 @keys Enum.map(@defaults, fn {k, _v} -> k end) 19 24 ··· 34 39 key = coordinator_config_prefix() <> Atom.to_string(k) 35 40 36 41 case List.keyfind(pairs, key, 0) do 37 - {^key, value} -> {k, String.to_integer(value)} 42 + {^key, value} -> {k, hd(Keyset.unpack(value))} 38 43 nil -> {k, v} 39 44 end 40 45 end) ··· 47 52 value = Map.fetch!(config, k) 48 53 { 49 54 coordinator_config_prefix() <> Atom.to_string(k), 50 - Integer.to_string(value), 55 + Keyset.pack([value]), 51 56 } 52 57 end) 53 58 end
+1 -2
lib/hobbes.ex
··· 98 98 99 99 config = ClusterConfig.from_opts(opts) 100 100 config_pairs = ClusterConfig.to_pairs(config) 101 - initial_shards_pairs = Keyword.get(opts, :initial_shards, [""]) |> Enum.map(fn k -> {"config/initial_shards/" <> k, ""} end) 102 - :ok = Coordinator.write(hd(coordinators), config_pairs ++ initial_shards_pairs) 101 + :ok = Coordinator.write(hd(coordinators), config_pairs) 103 102 104 103 { 105 104 :ok,
-9
lib/servers/manager.ex
··· 889 889 end 890 890 891 891 defp load_config(pairs) when is_list(pairs) do 892 - initial_shards = 893 - Enum.reduce(pairs, [], fn 894 - {"config/initial_shards/" <> shard_key, ""}, acc -> [shard_key | acc] 895 - {_, _}, acc -> acc 896 - end) 897 - |> Enum.reverse() 898 - 899 892 fields = 900 893 ClusterConfig.from_pairs(pairs) 901 894 |> Map.from_struct() 902 - |> Map.put(:initial_shards, initial_shards) 903 - |> Map.put(:num_replicas, 3) 904 895 struct!(Config, fields) 905 896 end 906 897