File: client_main.cc

package info (click to toggle)
srpc 0.10.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,100 kB
  • sloc: cpp: 23,170; python: 10; makefile: 8; sh: 6
file content (53 lines) | stat: -rw-r--r-- 1,126 bytes parent folder | download | duplicates (2)
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
#include <stdio.h>
#include <signal.h>
#include "workflow/%sMessage.h"
#include "workflow/WFTaskFactory.h"
#include "workflow/WFFacilities.h"

#include "config/config.h"

static WFFacilities::WaitGroup wait_group(1);
static srpc::RPCConfig config;

void sig_handler(int signo)
{
    wait_group.done();
}

void init()
{
    if (config.load("./client.conf") == false)
    {
        perror("Load config failed");
        exit(1);
    }

    signal(SIGINT, sig_handler);
    signal(SIGTERM, sig_handler);
}

void callback(WF%sTask *task)
{
    int state = task->get_state();
    int error = task->get_error();
    fprintf(stderr, "%s client state = %%d error = %%d\n", state, error);
%s
}

int main()
{
    init();

    std::string url = std::string("%s://") + %sconfig.client_host() +
                      std::string(":") + std::to_string(config.client_port());

    WF%sTask *task = WFTaskFactory::create_%s_task(url,%s
                                                        config.retry_max(),
                                                        callback);
%s
    task->start();

    wait_group.wait();
    return 0;
}