1 (* HCoop
Domtool (http
://hcoop
.sourceforge
.net
/)
2 * Copyright (c
) 2014 Clinton Ebadi
<clinton@unknownlamer
.org
>
4 * This program is free software
; you can redistribute it
and/or
5 * modify it under the terms
of the GNU General Public License
6 * as published by the Free Software Foundation
; either version
2
7 * of the License
, or (at your option
) any later version
.
9 * This program is distributed
in the hope that it will be useful
,
10 * but WITHOUT ANY WARRANTY
; without even the implied warranty
of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
. See the
12 * GNU General Public License for more details
.
14 * You should have received a copy
of the GNU General Public License
15 * along
with this program
; if not
, write to the Free Software
16 * Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
19 structure Connect
:> CONNECT
= struct
23 fun requestDispatcherBio context
=
24 OpenSSL
.connect
true (context
, Domain
.nodeIp Config
.dispatcherName ^
":" ^
Int.toString Config
.dispatcherPort
)
26 fun requestWorkerBio (context
, node
) =
27 OpenSSL
.connect
true (context
, Domain
.nodeIp node ^
":" ^
Int.toString Config
.slavePort
)
29 fun commandWorker (context
, node
, message
) =
30 (* It might be worth making this context
-> node
-> message
-> bool *)
32 val bio
= requestWorkerBio (context
, node
)
34 Msg
.send (bio
, message
);
36 NONE
=> (print
"Slave closed connection unexpectedly\n";
40 MsgOk
=> (print ("Slave " ^ node ^
" finished\n");
42 | MsgError s
=> (print ("Slave " ^ node
43 ^
" returned error: " ^
46 | _
=> (print ("Slave " ^ node
47 ^
" returned unexpected command\n");
49 before OpenSSL
.close bio
50 handle OpenSSL
.OpenSSL s
=> (print ("OpenSSL error: " ^ s ^
"\n");
53 handle OpenSSL
.OpenSSL _
=> false)
55 handle OpenSSL
.OpenSSL s
=> (print ("OpenSSL error: " ^ s ^
"\n");