bondy.hrl 4.51 KB
Newer Older
1 2
%% =============================================================================
%%  bondy.hrl -
3
%%
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
4
%%  Copyright (c) 2016-2019 Ngineo Limited t/a Leapsight. All rights reserved.
5
%%
6 7 8
%%  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
9
%%
10
%%     http://www.apache.org/licenses/LICENSE-2.0
11
%%
12 13 14 15 16 17 18
%%  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.
%% =============================================================================

19
-define(BONDY_REALM_URI, <<"com.leapsight.bondy">>).
20
-define(BONDY_PRIV_REALM_URI, <<"com.leapsight.bondy.private">>).
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
21

22
-define(BONDY_PEER_REQUEST, '$bondy_request').
23
-define(BONDY_PEER_ACK, '$bondy_ack').
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
24

25
-ifdef(OTP_RELEASE). %% => OTP is 21 or higher
26
-include_lib("kernel/include/logger.hrl").
27 28 29 30 31 32 33 34
-define(EXCEPTION(Class, Reason, Stacktrace), Class:Reason:Stacktrace).
-define(STACKTRACE(Stacktrace), Stacktrace).
-else.
-define(EXCEPTION(Class, Reason, _), Class:Reason).
-define(STACKTRACE(_), erlang:get_stacktrace()).
-endif.


Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
35 36 37 38 39 40 41 42 43

%% =============================================================================
%% FEATURES
%% =============================================================================




-define(DEALER_FEATURES, #{
44 45 46 47 48 49 50 51 52 53
    progressive_call_results => false,
    progressive_calls => false,
    call_timeout => true,
    call_canceling => false,
    caller_identification => false,
    call_trustlevels => false,
    registration_meta_api => false,
    registration_revocation => false,
    session_meta_api => false,
    pattern_based_registration => true,
54
    reflection => false,
55 56
    shared_registration => true,
    sharded_registration => false
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
57 58 59
}).

-define(CALLEE_FEATURES, #{
60 61 62 63 64 65 66 67 68 69 70
    progressive_call_results => false,
    progressive_calls => false,
    call_timeout => true,
    call_canceling => false,
    caller_identification => false,
    call_trustlevels => false,
    registration_revocation => false,
    session_meta_api => false,
    pattern_based_registration => true,
    shared_registration => true,
    sharded_registration => false
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
71 72 73
}).

-define(CALLER_FEATURES, #{
74 75
    progressive_call_results => false,
    progressive_calls => false,
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
76
    call_timeout => true,
77 78
    call_canceling => false,
    caller_identification => false
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
79 80 81
}).

-define(BROKER_FEATURES, #{
82 83 84 85 86 87 88 89 90
    event_history => false,
    pattern_based_subscription => true,
    publication_trustlevels => false,
    publisher_exclusion => false,
    publisher_identification => false,
    session_meta_api => false,
    sharded_subscription => false,
    subscriber_blackwhite_listing => false,
    subscription_meta_api => false,
91
    reflection => false
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
92 93 94
}).

-define(SUBSCRIBER_FEATURES, #{
95 96 97 98 99
    event_history => false,
    pattern_based_subscription => true,
    publication_trustlevels => false,
    publisher_identification => false,
    sharded_subscription => false
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
100 101 102
}).

-define(PUBLISHER_FEATURES, #{
103 104 105
    publisher_exclusion => false,
    publisher_identification => false,
    subscriber_blackwhite_listing => false
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
106 107 108 109 110
}).




111 112 113 114 115 116 117 118 119
%% =============================================================================
%% GENERAL
%% =============================================================================


-define(BONDY_ERROR_NOT_IN_SESSION, <<"com.leapsight.bondy.error.not_in_session">>).
-define(BONDY_SESSION_ALREADY_EXISTS, <<"com.leapsight.bondy.error.session_already_exists">>).

-define(BONDY_ERROR_TIMEOUT, <<"com.leapsight.bondy.error.timeout">>).
120
-define(BONDY_INCONSISTENCY_ERROR, <<"com.leapsight.bondy.error.unknown_error">>).
121 122 123 124 125 126 127

-type local_peer_id()   ::  {
    Realm       ::  binary(),
    Node        ::  atom(),
    SessionId   ::  integer() | undefined,
    Pid         ::  pid()
}.
128
-type remote_peer_id()  ::  {
129 130 131 132 133
    Realm       ::  binary(),
    Node        ::  atom(),
    SessionId   ::  integer() | undefined,
    Pid         ::  pid() | list() |undefined
}.
134
-type peer_id()         ::  local_peer_id() | remote_peer_id().
Ramallo Alejandro M.'s avatar
Ramallo Alejandro M. committed
135 136 137 138 139 140 141 142 143 144 145





%% =============================================================================
%% UTILS
%% =============================================================================

-define(EOT, '$end_of_table').
-define(CHARS2BIN(Chars), unicode:characters_to_binary(Chars, utf8, utf8)).
146
-define(CHARS2LIST(Chars), unicode:characters_to_list(Chars, utf8)).