github.com/distbuild/reclient@v0.0.0-20240401075343-3de72e395564/cmd/scandeps/server/server.h (about)

     1  // Copyright 2023 Google LLC
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  #ifndef CMD_SCANDEPS_SERVER_SERVER_H_
    16  #define CMD_SCANDEPS_SERVER_SERVER_H_
    17  
    18  #include <grpcpp/grpcpp.h>
    19  
    20  #include <condition_variable>
    21  #include <ctime>
    22  #include <memory>
    23  #include <string>
    24  
    25  class ScandepsServer {
    26   public:
    27    ScandepsServer(const std::string &server_address,
    28                   const std::string &cache_dir, const std::string &log_dir,
    29                   int cache_size_max_mb, bool use_deps_cache,
    30                   uint32_t shutdown_delay_seconds,
    31                   uint32_t experimental_deadlock,
    32                   uint32_t experimental_segfault);
    33    ~ScandepsServer();
    34  
    35    bool RunServer(const char *process_name);
    36    void StopServer();
    37  
    38   private:
    39    std::unique_ptr<grpc::Server> grpc_server_;
    40  
    41    bool running_;
    42    std::condition_variable shutdown_condition_;
    43    std::mutex shutdown_mutex_;
    44  
    45    const std::string server_address_;
    46    const std::string cache_dir_;
    47    const std::string log_dir_;
    48    int cache_size_max_mb_;
    49    bool use_deps_cache_;
    50    uint32_t shutdown_delay_seconds_;
    51  
    52    // Configurations used for experiments
    53    uint32_t experimental_deadlock_;
    54    uint32_t experimental_segfault_;
    55  };
    56  
    57  #endif  // CMD_SCANDEPS_SERVER_SERVER_H_