forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_server.cc
More file actions
62 lines (51 loc) · 2.07 KB
/
Copy pathtest_server.cc
File metadata and controls
62 lines (51 loc) · 2.07 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
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.
// Example server implementation to use for unit testing and benchmarking
// purposes
#include <signal.h>
#include <iostream>
#include <memory>
#include <string>
#include <gflags/gflags.h>
#include "arrow/flight/server.h"
#include "arrow/flight/test_util.h"
#include "arrow/flight/types.h"
#include "arrow/util/logging.h"
DEFINE_int32(port, 31337, "Server port to listen on");
DEFINE_string(unix, "", "Unix socket path to listen on");
std::unique_ptr<arrow::flight::FlightServerBase> g_server;
int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
g_server = arrow::flight::ExampleTestServer();
arrow::flight::Location location;
if (FLAGS_unix.empty()) {
location = *arrow::flight::Location::ForGrpcTcp("0.0.0.0", FLAGS_port);
} else {
location = *arrow::flight::Location::ForGrpcUnix(FLAGS_unix);
}
arrow::flight::FlightServerOptions options(location);
ARROW_CHECK_OK(g_server->Init(options));
// Exit with a clean error code (0) on SIGTERM
ARROW_CHECK_OK(g_server->SetShutdownOnSignals({SIGTERM}));
if (FLAGS_unix.empty()) {
std::cout << "Server listening on localhost:" << FLAGS_port << std::endl;
} else {
std::cout << "Server listening on unix://" << FLAGS_unix << std::endl;
}
ARROW_CHECK_OK(g_server->Serve());
return 0;
}