Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
grpc_server_test.h
Go to the documentation of this file.
1 // Copyright 2016 Google Inc.
16 
17 #ifndef PAGESPEED_CONTROLLER_GRPC_SERVER_TEST_H_
18 #define PAGESPEED_CONTROLLER_GRPC_SERVER_TEST_H_
19 
20 #include <memory>
21 
28 
29 namespace net_instaweb {
30 
33 class GrpcServerTest : public testing::Test {
34  public:
36  virtual ~GrpcServerTest();
37 
39  void SetUp() override;
40 
42  void StopServer();
43 
47 
48  GoogleString ServerAddress() const;
49 
50  protected:
53  public:
54  BaseClientConnection(const GoogleString& address)
55  : channel_(::grpc::CreateChannel(
56  address, ::grpc::InsecureChannelCredentials())) {
57  }
58 
59  ::grpc::ClientContext client_ctx_;
60  std::shared_ptr<::grpc::Channel> channel_;
61  };
62 
63  std::unique_ptr<ThreadSystem> thread_system_;
64  std::unique_ptr<::grpc::ServerCompletionQueue> queue_;
65 
66  private:
67  class GrpcServerThread : public ThreadSystem::Thread {
68  public:
69  GrpcServerThread(::grpc::CompletionQueue* queue,
70  ThreadSystem* thread_system);
71  virtual ~GrpcServerThread();
72  void Stop();
73 
74  private:
75  void Run() override;
76 
77  ::grpc::CompletionQueue* queue_;
78  };
79 
81  virtual void RegisterServices(::grpc::ServerBuilder*) = 0;
82 
83  std::unique_ptr<GrpcServerThread> server_thread_;
84  std::unique_ptr<::grpc::Server> server_;
85 };
86 
87 }
88 
89 #endif
Definition: grpc_server_test.h:33
Holder for various pieces of a client connection.
Definition: grpc_server_test.h:52
Definition: function.h:47
void SetUp() override
Binds server_ to the address returned by ListenAddress().
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
void QueueFunctionForServerThread(Function *func)
void StopServer()
Blocks until server_ is stopped.
Definition: thread_system.h:40
Base class for client thread code.
Definition: thread.h:34