添加依赖

Description 说明

object service.adddependencies(object/array **serviceDependencies**)

This method allows to create dependencies between services. 此方法允许创建服务之间的依赖关系。

Parameters 参数

(object/array) Service dependencies to create. (object/array)创建服务依赖关系。

Each service dependency has the following parameters. 每个服务依赖项具有以下参数。

Parameter 参数Type 类型Description 说明
serviceidstring 字符串ID of the service that depends on a service, that is, the parent service. 依赖父服务的服务ID。
dependsOnServiceidstring 字符串ID of the service that a service depends on, that is, the child service. 被子服务依赖的服务ID。
softstring 字符串Type of dependency. 依赖类型。

Refer to the service dependency object page for more information on dependency types. 有关依赖关系类型的更多信息,请参阅service dependency object page

Return values 返回值

(object) Returns an object containing the IDs of the affected parent services under the serviceids property. (object)返回一个对象,该对象包含在serviceids属性中受影响父服务的ID。

Examples 范例

Creating a hard dependency 创建一个硬依赖

Make service “2” a hard-dependent child of service “3”. 使服务“2”成为服务“3”强依赖的子服务。

Request 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "service.adddependencies",
  4. "params": {
  5. "serviceid": "3",
  6. "dependsOnServiceid": "2",
  7. "soft": 0
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "serviceids": [
  5. "3"
  6. ]
  7. },
  8. "id": 1
  9. }

See also 参考

Source 源码

CService::addDependencies() in frontends/php/include/classes/api/services/CService.php. CService::addDependencies()方法可在frontends/php/include/classes/api/services/CService.php中参考。