polaris-python 0.0.1.dev3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. polaris/__init__.py +74 -0
  2. polaris/_version.py +16 -0
  3. polaris/api/__init__.py +55 -0
  4. polaris/api/_log_file.py +232 -0
  5. polaris/api/config.py +145 -0
  6. polaris/api/consumer.py +240 -0
  7. polaris/api/log.py +414 -0
  8. polaris/api/lossless.py +73 -0
  9. polaris/api/provider.py +152 -0
  10. polaris/api/skill.py +162 -0
  11. polaris/pkg/__init__.py +15 -0
  12. polaris/pkg/common/__init__.py +15 -0
  13. polaris/pkg/common/plugin.py +33 -0
  14. polaris/pkg/config/__init__.py +15 -0
  15. polaris/pkg/config/api.py +1205 -0
  16. polaris/pkg/config/default.py +92 -0
  17. polaris/pkg/config/event.py +76 -0
  18. polaris/pkg/config/loader.py +392 -0
  19. polaris/pkg/config/stat_reporter.py +100 -0
  20. polaris/pkg/flow/__init__.py +15 -0
  21. polaris/pkg/flow/admin_server.py +104 -0
  22. polaris/pkg/flow/async_flow.py +55 -0
  23. polaris/pkg/flow/base_flow.py +111 -0
  24. polaris/pkg/flow/impl.py +1277 -0
  25. polaris/pkg/flow/lossless.py +605 -0
  26. polaris/pkg/flow/notify.py +46 -0
  27. polaris/pkg/flow/register.py +210 -0
  28. polaris/pkg/flow/skill.py +110 -0
  29. polaris/pkg/flow/sync_flow.py +20 -0
  30. polaris/pkg/model/__init__.py +15 -0
  31. polaris/pkg/model/context.py +53 -0
  32. polaris/pkg/model/contract.py +89 -0
  33. polaris/pkg/model/core.py +51 -0
  34. polaris/pkg/model/engine.py +83 -0
  35. polaris/pkg/model/error.py +94 -0
  36. polaris/pkg/model/event.py +159 -0
  37. polaris/pkg/model/lossless.py +102 -0
  38. polaris/pkg/model/rule.py +152 -0
  39. polaris/pkg/model/server.py +288 -0
  40. polaris/pkg/model/service.py +820 -0
  41. polaris/pkg/model/skill.py +179 -0
  42. polaris/pkg/model/stat.py +168 -0
  43. polaris/pkg/model/util.py +58 -0
  44. polaris/pkg/version/__init__.py +18 -0
  45. polaris/plugin/__init__.py +32 -0
  46. polaris/plugin/circuit_breaker/__init__.py +19 -0
  47. polaris/plugin/circuit_breaker/base.py +54 -0
  48. polaris/plugin/circuit_breaker/composite.py +265 -0
  49. polaris/plugin/circuit_breaker/config.py +36 -0
  50. polaris/plugin/event/__init__.py +21 -0
  51. polaris/plugin/event/pushgateway.py +202 -0
  52. polaris/plugin/load_balancer/__init__.py +24 -0
  53. polaris/plugin/load_balancer/base.py +30 -0
  54. polaris/plugin/load_balancer/random.py +39 -0
  55. polaris/plugin/load_balancer/weighted_random.py +50 -0
  56. polaris/plugin/local_registry/__init__.py +18 -0
  57. polaris/plugin/local_registry/base.py +47 -0
  58. polaris/plugin/local_registry/file_cache.py +335 -0
  59. polaris/plugin/local_registry/local_cache.py +433 -0
  60. polaris/plugin/server_connector/__init__.py +20 -0
  61. polaris/plugin/server_connector/base.py +104 -0
  62. polaris/plugin/server_connector/convert.py +149 -0
  63. polaris/plugin/server_connector/grpc_connector/__init__.py +21 -0
  64. polaris/plugin/server_connector/grpc_connector/connection.py +401 -0
  65. polaris/plugin/server_connector/grpc_connector/grpc_client.py +384 -0
  66. polaris/plugin/server_connector/grpc_connector/tls.py +45 -0
  67. polaris/plugin/service_router/__init__.py +28 -0
  68. polaris/plugin/service_router/base.py +105 -0
  69. polaris/plugin/service_router/isolated.py +35 -0
  70. polaris/plugin/service_router/metadata.py +84 -0
  71. polaris/plugin/service_router/recover.py +62 -0
  72. polaris/plugin/service_router/util.py +54 -0
  73. polaris/plugin/skill/__init__.py +16 -0
  74. polaris/plugin/skill/connector.py +127 -0
  75. polaris/plugin/skill/persistence.py +94 -0
  76. polaris/plugin/stat_reporter/__init__.py +16 -0
  77. polaris/plugin/stat_reporter/base.py +34 -0
  78. polaris/plugin/stat_reporter/prometheus.py +375 -0
  79. polaris/plugin_manager.py +146 -0
  80. polaris_python-0.0.1.dev3.dist-info/METADATA +213 -0
  81. polaris_python-0.0.1.dev3.dist-info/RECORD +84 -0
  82. polaris_python-0.0.1.dev3.dist-info/WHEEL +5 -0
  83. polaris_python-0.0.1.dev3.dist-info/licenses/LICENSE +18 -0
  84. polaris_python-0.0.1.dev3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,73 @@
1
+ # Tencent is pleased to support the open source community by making polaris-python available.
2
+ #
3
+ # Copyright (C) 2021 Tencent. All rights reserved.
4
+ #
5
+ # Licensed under the BSD 3-Clause License (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://opensource.org/licenses/BSD-3-Clause
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ """Public API for Java-compatible lossless online/offline."""
18
+
19
+ from polaris.api.config import SDKContext
20
+ from polaris.pkg.model.error import SDKError, ErrorCode
21
+ from polaris.pkg.model.lossless import LosslessActionProvider, LosslessInstance
22
+
23
+
24
+ class LosslessAPI:
25
+ """Drive lossless lifecycle with user-supplied register/deregister callbacks."""
26
+
27
+ def __init__(self, context: SDKContext):
28
+ self.context = context
29
+
30
+ def check_available(self):
31
+ if not self.context:
32
+ raise SDKError(ErrorCode.ErrCodeAPIInvalidArgument, "losslessAPI can not be None")
33
+ if self.context.is_destroy():
34
+ raise SDKError(ErrorCode.ErrCodeInvalidStateError, "losslessAPI: api instance has been destroyed")
35
+
36
+ def _manager(self):
37
+ manager = self.context.get_engine().lossless_manager
38
+ if manager is None:
39
+ raise SDKError(ErrorCode.ErrCodeInvalidStateError, "losslessAPI: engine has no lossless manager")
40
+ return manager
41
+
42
+ def set_lossless_action_provider(self, instance: LosslessInstance,
43
+ provider: LosslessActionProvider) -> None:
44
+ """Bind the callbacks used by lossless register/deregister for one instance."""
45
+ self.check_available()
46
+ if not isinstance(provider, LosslessActionProvider):
47
+ raise SDKError(ErrorCode.ErrCodeAPIInvalidArgument,
48
+ "losslessAPI: provider must implement LosslessActionProvider")
49
+ self._manager().set_action_provider(instance, provider)
50
+
51
+ def lossless_register(self, instance: LosslessInstance) -> None:
52
+ """Synchronously start lossless online for one instance."""
53
+ self.check_available()
54
+ engine = self.context.get_engine()
55
+ engine._run_sync(self._manager().lossless_register(instance))
56
+
57
+ async def async_lossless_register(self, instance: LosslessInstance) -> None:
58
+ """Asynchronously start lossless online for one instance."""
59
+ self.check_available()
60
+ engine = self.context.get_engine()
61
+ await engine._run_async(self._manager().lossless_register(instance))
62
+
63
+ def lossless_deregister(self, instance: LosslessInstance) -> None:
64
+ """Synchronously trigger lossless offline for one instance."""
65
+ self.check_available()
66
+ engine = self.context.get_engine()
67
+ engine._run_sync(self._manager().lossless_deregister(instance))
68
+
69
+ async def async_lossless_deregister(self, instance: LosslessInstance) -> None:
70
+ """Asynchronously trigger lossless offline for one instance."""
71
+ self.check_available()
72
+ engine = self.context.get_engine()
73
+ await engine._run_async(self._manager().lossless_deregister(instance))
@@ -0,0 +1,152 @@
1
+ # Tencent is pleased to support the open source community by making polaris-python available.
2
+ #
3
+ # Copyright (C) 2021 Tencent. All rights reserved.
4
+ #
5
+ # Licensed under the BSD 3-Clause License (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://opensource.org/licenses/BSD-3-Clause
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software distributed
12
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
14
+ # specific language governing permissions and limitations under the License.
15
+
16
+ from polaris.pkg.model.server import (
17
+ InstanceDeRegisterRequest,
18
+ InstanceHeartbeatRequest,
19
+ InstanceRegisterRequest,
20
+ InstanceRegisterResponse,
21
+ )
22
+ from polaris.pkg.config.api import Configuration
23
+ from polaris.pkg.model.error import SDKError, ErrorCode
24
+ from polaris.api.config import SDKContext, init_context_by_config, init_context_by_file
25
+ from polaris.api.log import LogOptions
26
+
27
+
28
+ class ProviderAPI:
29
+ """Register instances and manage their heartbeats through a shared SDK context."""
30
+
31
+ def __init__(self, context: SDKContext):
32
+ self.context = context
33
+
34
+ def check_available(self):
35
+ if not self.context:
36
+ raise SDKError(ErrorCode.ErrCodeAPIInvalidArgument, "providerAPI can not be None")
37
+ if self.context.is_destroy():
38
+ raise SDKError(ErrorCode.ErrCodeInvalidStateError, "providerAPI: api instance has been destroyed")
39
+
40
+ def register(self, request: InstanceRegisterRequest) -> InstanceRegisterResponse:
41
+ """Register synchronously, using the request's automatic-heartbeat setting."""
42
+ self.check_available()
43
+ request.validate()
44
+ return self.context.get_engine().sync_register(request)
45
+
46
+ def register_instance(self, request: InstanceRegisterRequest) -> InstanceRegisterResponse:
47
+ """Register synchronously and let the SDK maintain instance heartbeats."""
48
+ self.check_available()
49
+ request.validate()
50
+ request.auto_heartbeat = True
51
+ return self.context.get_engine().sync_register(request)
52
+
53
+ def deregister(self, request: InstanceDeRegisterRequest) -> None:
54
+ """Stop automatic heartbeats and synchronously deregister the instance."""
55
+ self.check_available()
56
+ request.validate()
57
+ return self.context.get_engine().sync_deregister(request)
58
+
59
+ def heartbeat(self, request: InstanceHeartbeatRequest) -> None:
60
+ """Synchronously send one explicit instance heartbeat."""
61
+ self.check_available()
62
+ request.validate()
63
+ return self.context.get_engine().sync_heartbeat(request)
64
+
65
+ def deregister_instance(self, request: InstanceDeRegisterRequest) -> None:
66
+ """Stop automatic heartbeats and synchronously deregister an instance."""
67
+ return self.deregister(request)
68
+
69
+ def lossless_register(self, request: InstanceRegisterRequest) -> None:
70
+ """Delay or health-check gate registration for lossless online."""
71
+ self.check_available()
72
+ request.validate()
73
+ return self.context.get_engine().sync_lossless_register(request)
74
+
75
+ def lossless_deregister(self, request) -> None:
76
+ """Deregister immediately so consumers stop routing to the instance."""
77
+ self.check_available()
78
+ request.validate()
79
+ return self.context.get_engine().sync_lossless_deregister(request)
80
+
81
+ async def async_register(self, request: InstanceRegisterRequest) -> InstanceRegisterResponse:
82
+ """Asynchronously register with the request's automatic-heartbeat setting."""
83
+ self.check_available()
84
+ request.validate()
85
+ return await self.context.get_engine().async_register(request)
86
+
87
+ async def async_register_instance(self, request: InstanceRegisterRequest) -> InstanceRegisterResponse:
88
+ """Asynchronously register and let the SDK maintain instance heartbeats."""
89
+ self.check_available()
90
+ request.validate()
91
+ request.auto_heartbeat = True
92
+ return await self.context.get_engine().async_register(request)
93
+
94
+ async def async_deregister(self, request: InstanceDeRegisterRequest) -> None:
95
+ """Stop automatic heartbeats and asynchronously deregister the instance."""
96
+ self.check_available()
97
+ request.validate()
98
+ return await self.context.get_engine().async_deregister(request)
99
+
100
+ async def async_heartbeat(self, request: InstanceHeartbeatRequest) -> None:
101
+ """Asynchronously send one explicit instance heartbeat."""
102
+ self.check_available()
103
+ request.validate()
104
+ return await self.context.get_engine().async_heartbeat(request)
105
+
106
+ async def async_deregister_instance(self, request: InstanceDeRegisterRequest) -> None:
107
+ """Stop automatic heartbeats and asynchronously deregister an instance."""
108
+ return await self.async_deregister(request)
109
+
110
+ async def async_lossless_register(self, request: InstanceRegisterRequest) -> None:
111
+ """Asynchronously delay or health-check gate registration."""
112
+ self.check_available()
113
+ request.validate()
114
+ return await self.context.get_engine().async_lossless_register(request)
115
+
116
+ async def async_lossless_deregister(self, request) -> None:
117
+ """Asynchronously deregister immediately for lossless offline."""
118
+ self.check_available()
119
+ request.validate()
120
+ return await self.context.get_engine().async_lossless_deregister(request)
121
+
122
+ def report_service_contract(self, request):
123
+ """Synchronously report tools, resources, prompts and handler descriptors."""
124
+ self.check_available()
125
+ request.validate()
126
+ return self.context.get_engine().sync_contract_call("report_service_contract", request)
127
+
128
+ async def async_report_service_contract(self, request):
129
+ """Asynchronously report a service contract."""
130
+ self.check_available()
131
+ request.validate()
132
+ return await self.context.get_engine().async_contract_call("report_service_contract", request)
133
+
134
+ def destroy(self) -> None:
135
+ """Destroy the shared context and stop all of its heartbeat tasks."""
136
+ if self.context:
137
+ self.context.destroy()
138
+
139
+
140
+ def create_provider_by_file(path: str, *, log_options: LogOptions | None = None) -> ProviderAPI:
141
+ context = init_context_by_file(path=path, log_options=log_options)
142
+ return ProviderAPI(context=context)
143
+
144
+
145
+ def create_provider_by_config(config: Configuration, *, log_options: LogOptions | None = None) -> ProviderAPI:
146
+ context = init_context_by_config(config=config, log_options=log_options)
147
+ return ProviderAPI(context=context)
148
+
149
+
150
+ def create_provider_by_default_config_file(*, log_options: LogOptions | None = None) -> ProviderAPI:
151
+ from polaris.api.config import init_context
152
+ return ProviderAPI(context=init_context(log_options=log_options))
polaris/api/skill.py ADDED
@@ -0,0 +1,162 @@
1
+ # Tencent is pleased to support the open source community by making polaris-python available.
2
+ #
3
+ # Copyright (C) 2021 Tencent. All rights reserved.
4
+ #
5
+ # Licensed under the BSD 3-Clause License (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://opensource.org/licenses/BSD-3-Clause
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software distributed
12
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
14
+ # specific language governing permissions and limitations under the License.
15
+
16
+ """Read-only published Skill APIs with synchronous and asynchronous entry points."""
17
+
18
+ from polaris.api.config import init_context_by_config, init_context_by_file
19
+ from polaris.pkg.model.error import ErrorCode, SDKError
20
+ from polaris.pkg.model.service import ExtendedMetadata, ServiceInstances
21
+ from polaris.pkg.model.skill import SkillDownloadRequest, SkillGetRequest, SkillListRequest
22
+
23
+
24
+ class SkillAPI:
25
+ """Query and download published skills through a shared SDK context."""
26
+
27
+ def __init__(self, context, *, owns_context=False):
28
+ self.context = context
29
+ self._owns_context = owns_context
30
+ self._closed = False
31
+
32
+ def _check(self, request):
33
+ if self._closed or self.context is None or self.context.is_destroy():
34
+ raise SDKError(ErrorCode.ErrCodeInvalidStateError, "Skill API or context has been destroyed")
35
+ request.validate()
36
+
37
+ def resolve_mounted_skill_request(self, service_snapshot, *, skill_name: str = "",
38
+ requested_version: str = "", timeout: int = 0) -> SkillGetRequest:
39
+ """Resolve one mounted skill, preferring its recorded version over the caller version."""
40
+ if self._closed or self.context is None or self.context.is_destroy():
41
+ raise SDKError(ErrorCode.ErrCodeInvalidStateError, "Skill API or context has been destroyed")
42
+ if not isinstance(service_snapshot, ServiceInstances):
43
+ raise SDKError(ErrorCode.ErrCodeAPIInvalidArgument, "service_snapshot must be a ServiceInstances")
44
+ if not isinstance(skill_name, str) or not isinstance(requested_version, str) or type(timeout) is not int:
45
+ raise SDKError(ErrorCode.ErrCodeAPIInvalidArgument,
46
+ "skill_name and requested_version must be strings and timeout must be an integer")
47
+
48
+ mounts = [item.agent_skill for item in service_snapshot.get_extended_metadata()
49
+ if item.type == ExtendedMetadata.SKILL and item.agent_skill is not None]
50
+ if skill_name:
51
+ mounts = [mount for mount in mounts if mount.name == skill_name]
52
+ elif len(mounts) > 1:
53
+ raise SDKError(ErrorCode.ErrCodeAPIInvalidArgument,
54
+ "service has multiple mounted skills; specify skill_name")
55
+ if not mounts:
56
+ raise SDKError(ErrorCode.ErrCodeAPIInvalidArgument, "service has no matching mounted skill")
57
+
58
+ mount = mounts[0]
59
+ if not mount.name:
60
+ raise SDKError(ErrorCode.ErrCodeAPIInvalidArgument, "mounted skill name is empty")
61
+ version = mount.version or requested_version
62
+ request = SkillGetRequest(service_snapshot.get_namespace(), mount.name, version, timeout)
63
+ request.validate()
64
+ return request
65
+
66
+ def get_skill(self, request: SkillGetRequest):
67
+ """Synchronously fetch published content with network-error fallback."""
68
+ self._check(request)
69
+ return self.context.engine.sync_skill_call("get_skill", request)
70
+
71
+ async def async_get_skill(self, request: SkillGetRequest):
72
+ """Asynchronously fetch published content with network-error fallback."""
73
+ self._check(request)
74
+ return await self.context.engine.async_skill_call("get_skill", request)
75
+
76
+ def list_skills(self, request: SkillListRequest):
77
+ """Synchronously search published skills on the remote server."""
78
+ self._check(request)
79
+ return self.context.engine.sync_skill_call("list_skills", request)
80
+
81
+ async def async_list_skills(self, request: SkillListRequest):
82
+ """Asynchronously search published skills on the remote server."""
83
+ self._check(request)
84
+ return await self.context.engine.async_skill_call("list_skills", request)
85
+
86
+ def download_skill(self, request: SkillDownloadRequest):
87
+ """Synchronously download a complete markdown or ZIP payload."""
88
+ self._check(request)
89
+ return self.context.engine.sync_skill_call("download_skill", request)
90
+
91
+ def get_mounted_skill(self, service_snapshot, *, skill_name: str = "", requested_version: str = "",
92
+ timeout: int = 0):
93
+ """Synchronously fetch the skill mounted on a discovered service."""
94
+ request = self.resolve_mounted_skill_request(
95
+ service_snapshot, skill_name=skill_name, requested_version=requested_version, timeout=timeout)
96
+ return self.get_skill(request)
97
+
98
+ async def async_get_mounted_skill(self, service_snapshot, *, skill_name: str = "",
99
+ requested_version: str = "", timeout: int = 0):
100
+ """Asynchronously fetch the skill mounted on a discovered service."""
101
+ request = self.resolve_mounted_skill_request(
102
+ service_snapshot, skill_name=skill_name, requested_version=requested_version, timeout=timeout)
103
+ return await self.async_get_skill(request)
104
+
105
+ def download_mounted_skill(self, service_snapshot, *, skill_name: str = "", requested_version: str = "",
106
+ timeout: int = 0, format: str = "markdown"):
107
+ """Synchronously download the skill mounted on a discovered service."""
108
+ request = self.resolve_mounted_skill_request(
109
+ service_snapshot, skill_name=skill_name, requested_version=requested_version, timeout=timeout)
110
+ download = SkillDownloadRequest(request.namespace, request.name, request.version, timeout, format=format)
111
+ return self.download_skill(download)
112
+
113
+ async def async_download_mounted_skill(self, service_snapshot, *, skill_name: str = "",
114
+ requested_version: str = "", timeout: int = 0,
115
+ format: str = "markdown"):
116
+ """Asynchronously download the skill mounted on a discovered service."""
117
+ request = self.resolve_mounted_skill_request(
118
+ service_snapshot, skill_name=skill_name, requested_version=requested_version, timeout=timeout)
119
+ download = SkillDownloadRequest(request.namespace, request.name, request.version, timeout, format=format)
120
+ return await self.async_download_skill(download)
121
+
122
+ async def async_download_skill(self, request: SkillDownloadRequest):
123
+ """Asynchronously download a complete markdown or ZIP payload."""
124
+ self._check(request)
125
+ return await self.context.engine.async_skill_call("download_skill", request)
126
+
127
+ def destroy(self):
128
+ """Close this API and its context only when the factory created that context."""
129
+ self._closed = True
130
+ if self._owns_context and self.context is not None:
131
+ self.context.destroy()
132
+
133
+ def close(self):
134
+ """Java AutoCloseable-compatible alias for destroy()."""
135
+ self.destroy()
136
+
137
+ def __enter__(self):
138
+ return self
139
+
140
+ def __exit__(self, *_):
141
+ self.close()
142
+
143
+
144
+ def create_skill_by_config(config, *, log_options=None):
145
+ """Create a Skill API owning an independently configured context."""
146
+ return SkillAPI(init_context_by_config(config, log_options=log_options), owns_context=True)
147
+
148
+
149
+ def create_skill_by_file(path, *, log_options=None):
150
+ """Create a Skill API owning a context loaded from polaris.yaml."""
151
+ return SkillAPI(init_context_by_file(path, log_options=log_options), owns_context=True)
152
+
153
+
154
+ def create_skill_by_context(context):
155
+ """Create a Skill API that shares a caller-owned SDK context."""
156
+ return SkillAPI(context)
157
+
158
+
159
+ def create_skill_by_default_config_file(*, log_options=None):
160
+ """Create a Skill API from the default polaris.yaml or environment."""
161
+ from polaris.api.config import init_context
162
+ return SkillAPI(init_context(log_options=log_options), owns_context=True)
@@ -0,0 +1,15 @@
1
+ # Tencent is pleased to support the open source community by making polaris-python available.
2
+ #
3
+ # Copyright (C) 2021 Tencent. All rights reserved.
4
+ #
5
+ # Licensed under the BSD 3-Clause License (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://opensource.org/licenses/BSD-3-Clause
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software distributed
12
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
14
+ # specific language governing permissions and limitations under the License.
15
+
@@ -0,0 +1,15 @@
1
+ # Tencent is pleased to support the open source community by making polaris-python available.
2
+ #
3
+ # Copyright (C) 2021 Tencent. All rights reserved.
4
+ #
5
+ # Licensed under the BSD 3-Clause License (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://opensource.org/licenses/BSD-3-Clause
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software distributed
12
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
14
+ # specific language governing permissions and limitations under the License.
15
+
@@ -0,0 +1,33 @@
1
+ # Tencent is pleased to support the open source community by making polaris-python available.
2
+ #
3
+ # Copyright (C) 2021 Tencent. All rights reserved.
4
+ #
5
+ # Licensed under the BSD 3-Clause License (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://opensource.org/licenses/BSD-3-Clause
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software distributed
12
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
14
+ # specific language governing permissions and limitations under the License.
15
+
16
+ from abc import abstractmethod
17
+
18
+ from polaris.pkg.config import api
19
+ from polaris.plugin_manager import PluginType
20
+
21
+
22
+ class Supplier:
23
+ @abstractmethod
24
+ def get_plugin(cls, type: PluginType, name: str):
25
+ pass
26
+
27
+
28
+ class InitContext:
29
+ def __init__(self, config: api.Configuration, plugins: Supplier, value_ctx, conn_manager):
30
+ self.config = config
31
+ self.plugins = plugins
32
+ self.value_ctx = value_ctx
33
+ self.conn_manager = conn_manager
@@ -0,0 +1,15 @@
1
+ # Tencent is pleased to support the open source community by making polaris-python available.
2
+ #
3
+ # Copyright (C) 2021 Tencent. All rights reserved.
4
+ #
5
+ # Licensed under the BSD 3-Clause License (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://opensource.org/licenses/BSD-3-Clause
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software distributed
12
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
14
+ # specific language governing permissions and limitations under the License.
15
+