diff --git a/consumers/course_service.php b/consumers/course_service.php new file mode 100644 index 0000000..6791a37 --- /dev/null +++ b/consumers/course_service.php @@ -0,0 +1,44 @@ + 'CourseService', + // 服务接口名 + 'service' => CourseServiceInterface::class, + // 服务提供者的服务协议,可选,默认值为 jsonrpc-http + 'protocol' => 'jsonrpc-http', + // 负载均衡算法,可选,默认值为 random + 'load_balancer' => 'random', + // 这个消费者要从哪个服务中心获取节点信息,如不配置则不会从服务中心获取节点信息 + 'registry' => [ + 'protocol' => env('CONSUMERS_PROTOCOL', 'consul'), + 'address' => env('CONSUMERS_ADDRESS', 'http://127.0.0.1:8500'), + ], + // 配置项,会影响到 Packer 和 Transporter + 'options' => [ + 'connect_timeout' => 5.0, + 'recv_timeout' => 5.0, + 'settings' => [ + 'open_eof_split' => true, + 'package_eof' => "\r\n", + ], + 'retry_count' => 2, + 'retry_interval' => 100, + 'heartbeat' => 30, + 'pool' => [ + 'min_connections' => 1, + 'max_connections' => 32, + 'connect_timeout' => 10.0, + 'wait_timeout' => 3.0, + 'heartbeat' => -1, + 'max_idle_time' => 60.0, + ], + ], +]; diff --git a/consumers/exam_service.php b/consumers/exam_service.php new file mode 100644 index 0000000..4ef2b8c --- /dev/null +++ b/consumers/exam_service.php @@ -0,0 +1,40 @@ + 'ExamService', + // 服务接口名 + 'service' => ExamServiceInterface::class, + // 服务提供者的服务协议,可选,默认值为 jsonrpc-http + 'protocol' => 'jsonrpc-http', + // 负载均衡算法,可选,默认值为 random + 'load_balancer' => 'random', + // 这个消费者要从哪个服务中心获取节点信息,如不配置则不会从服务中心获取节点信息 + 'registry' => [ + 'protocol' => env('CONSUMERS_PROTOCOL', 'consul'), + 'address' => env('CONSUMERS_ADDRESS', 'http://127.0.0.1:8500'), + ], + // 配置项,会影响到 Packer 和 Transporter + 'options' => [ + 'connect_timeout' => 5.0, + 'recv_timeout' => 5.0, + 'settings' => [ + 'open_eof_split' => true, + 'package_eof' => "\r\n", + ], + 'retry_count' => 2, + 'retry_interval' => 100, + 'heartbeat' => 30, + 'pool' => [ + 'min_connections' => 1, + 'max_connections' => 32, + 'connect_timeout' => 10.0, + 'wait_timeout' => 3.0, + 'heartbeat' => -1, + 'max_idle_time' => 60.0, + ], + ], +]; diff --git a/src/DataService/Course/CourseServiceInterface.php b/src/CourseService/CourseServiceInterface.php similarity index 87% rename from src/DataService/Course/CourseServiceInterface.php rename to src/CourseService/CourseServiceInterface.php index 8a34700..0ffc725 100644 --- a/src/DataService/Course/CourseServiceInterface.php +++ b/src/CourseService/CourseServiceInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Dhd\Micro\Interface\DataService\Course; +namespace Dhd\Micro\Interface\CourseService; /** * 课程服务接口 diff --git a/src/DataService/DataService.php b/src/DataService/DataService.php index 6e0e219..34238d4 100644 --- a/src/DataService/DataService.php +++ b/src/DataService/DataService.php @@ -6,9 +6,6 @@ namespace Dhd\Micro\Interface\DataService; -use Dhd\Micro\Interface\DataService\Course\CourseServiceInterface; -use Dhd\Micro\Interface\DataService\Exam\ExamServiceInterface; - interface DataService extends DataServiceInterface, AgreementInterface, @@ -24,6 +21,4 @@ interface DataService extends ExcelHeaderFieldsInterface, DictionaryInterface, MajorsInterface, - GuideNavInterface, - CourseServiceInterface, - ExamServiceInterface {} + GuideNavInterface {} diff --git a/src/DataService/Exam/ExamServiceInterface.php b/src/ExamService/ExamServiceInterface.php similarity index 99% rename from src/DataService/Exam/ExamServiceInterface.php rename to src/ExamService/ExamServiceInterface.php index bb374ac..19c8a83 100644 --- a/src/DataService/Exam/ExamServiceInterface.php +++ b/src/ExamService/ExamServiceInterface.php @@ -1,6 +1,6 @@