You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

server.h 1.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MINDSPORE_SERVING_MASTER_SERVER_H
  17. #define MINDSPORE_SERVING_MASTER_SERVER_H
  18. #include <memory>
  19. #include <string>
  20. #include "common/serving_common.h"
  21. #include "common/grpc_server.h"
  22. #include "master/restful/restful_server.h"
  23. #include "master/dispacther.h"
  24. namespace mindspore {
  25. namespace serving {
  26. class MS_API Server {
  27. public:
  28. Server();
  29. ~Server();
  30. Status StartGrpcServer(const std::string &ip, uint32_t grpc_port, int max_msg_mb_size = gRpcDefaultMsgMBSize);
  31. Status StartGrpcMasterServer(const std::string &ip, uint32_t grpc_port);
  32. Status StartRestfulServer(const std::string &ip, uint32_t restful_port, int max_msg_mb_size = gRpcDefaultMsgMBSize,
  33. int time_out_second = 100);
  34. void Clear();
  35. std::shared_ptr<Dispatcher> GetDispatcher() { return dispatcher_; }
  36. static Server &Instance();
  37. private:
  38. GrpcServer grpc_server_;
  39. GrpcServer grpc_manager_server_;
  40. RestfulServer restful_server_;
  41. std::shared_ptr<Dispatcher> dispatcher_ = std::make_shared<Dispatcher>();
  42. };
  43. } // namespace serving
  44. } // namespace mindspore
  45. #endif // MINDSPORE_SERVING_MASTER_SERVER_H

A lightweight and high-performance service module that helps MindSpore developers efficiently deploy online inference services in the production environment.