%%%--------------------------------------------------------------------------- %%% Copyright (C) 2021, Fix Solution All Rights Reserved %%% Unauthorized copy of this file is through any medium strictly not allowed. %%% %%% Authors : Alpha Shaw %%% Created : 20 Apr 2021 by %%% Purpose : %%% %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%%--------------------------------------------------------------------------- -include_lib("erlwater/include/erlwater.hrl"). -define(FLAKE_EPOCH_MICROS, 1577836800000000). %% 00:00:00 01 January 2020 -ifdef(FLAKE_96). -define(TIMESTAMP_BITS, 64). -define(SEQUENCE_BITS, 16). -define(WORKER_BITS, 16). -define(FLAKE_BITS, 96). -else. -define(TIMESTAMP_BITS, 39). -define(SEQUENCE_BITS, 13). -define(WORKER_BITS, 12). -define(FLAKE_BITS, 64). -endif. -define(MAX_WORKER, (1 bsl ?WORKER_BITS) - 1). -define(MAX_SEQUENCE, (1 bsl ?SEQUENCE_BITS) - 1). -define(SEQUENCE_WORKER_BITS, ?SEQUENCE_BITS + ?WORKER_BITS). -define(DEFAULT_ZK_HOST, <<"localhost">>). -define(DEFAULT_ZK_PORT, 2181). -define(WORKER_ID_ENV_VAR, "ERLFLAKE_WORKER_ID"). -define(ZK_HOST_ENV_VAR, "ERLFLAKE_ZOOKEEPER_HOST"). -define(ZK_PORT_ENV_VAR, "ERLFLAKE_ZOOKEEPER_PORT").