Repository navigation
Expand file tree
/
Copy pathseaplus.hrl
More file actions
124 lines (90 loc) · 3.51 KB
/
Copy pathseaplus.hrl
File metadata and controls
124 lines (90 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
% Copyright (C) 2018-2026 Olivier Boudeville
%
% This file is part of the Ceylan-Seaplus library.
%
% This library is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License or
% the GNU General Public License, as they are published by the Free Software
% Foundation, either version 3 of these Licenses, or (at your option)
% any later version.
% You can also redistribute it and/or modify it under the terms of the
% Mozilla Public License, version 1.1 or later.
%
% This library is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License and the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License, of the GNU General Public License and of the Mozilla Public License
% along with this library.
% If not, see <http://www.gnu.org/licenses/> and
% <http://www.mozilla.org/MPL/>.
%
% Author: Olivier Boudeville [olivier (dot) boudeville (at) esperide (dot) com]
% Creation date: December 16, 2018
% This header file auto-defines the Seaplus base, generic service functions.
%
% It is meant to be included by the bridging modules (e.g. for a Foobar service,
% by foobar.erl).
-define( service_module_name, ?MODULE ).
-define( service_registration_name, ?service_module_name ).
-export([ % Base service behaviour:
% Auto-exported by the Seaplus parse transform:
% start/0, start_link/0, stop/0,
restart/0,
activate_seaplus/1 ]).
% The following start/0, start_link/0 and stop/0 functions are commented-out, as
% they are automatically defined appropriately by the Seaplus parse transform
% now.
% Starts the service.
%
% Preferred form, to detect crashes of the driver and/or of the integrated
% library: the current process will then trap EXIT signals, and thus Seaplus
% will throw a {driver_crashed, ErrorReason} exception if appropriate.
%
% As a result, the user code may catch this exception and react accordingly
% (e.g. by restarting the driver).
%
%-spec start() -> void().
%start() ->
% % Allows to register and identify target executable:
% seaplus:start( ?service_module_name ).
% Starts and links the service.
%
% The current process will then not trap EXIT signals, and thus will crash
% whenever its associated driver crashed (because of the driver itself, or
% because of the integrated library).
%
% Note that start/0 is the generally preferred form.
%
%-spec start_link() -> void().
%start_link() ->
% Allows to register and identify target executable:
% seaplus:start_link( ?service_module_name ).
% Restarts the support of this foobar service (e.g. to overcome a detected crash
% thereof).
%
% Note: performs a start/0, not a start_link/0.
%
-spec restart() -> void().
restart() ->
% So that user-code (not Seaplus one only) is triggered as well:
stop(),
start().
% Stops the service.
%-spec stop() -> void().
%stop() ->
% seaplus:stop( ?service_module_name ).
% None defined yet:
-type seaplus_option() :: any().
-ifndef(override_seaplus_activation).
% Simply defining that function allows to activate the Seaplus transformations
% for the current module (acts as a AST marker, and will be detected and removed
% by the Seaplus parse transform).
%
-spec activate_seaplus( [ seaplus_option() ] ) -> void().
activate_seaplus( Options ) ->
Options.
-endif. % override_seaplus_activation