├── LICENSE ├── MANIFEST.in ├── README.md ├── aion ├── __init__.py ├── kanban │ ├── __init__.py │ ├── async_kanban.py │ └── kanban.py ├── logger │ ├── __init__.py │ └── logger.py ├── microservice │ ├── __init__.py │ └── microservice.py ├── mongo │ ├── __init__.py │ └── query.py ├── mysql │ ├── __init__.py │ ├── install_amd.sh │ └── query.py └── proto │ ├── __init__.py │ ├── status_pb2.py │ └── status_pb2_grpc.py ├── requirements.txt ├── setup.py └── test ├── Dockerfile └── docker-compose.yml /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Latona, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include requirements.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## aion-related-python-library 2 | aion-related-python-libraryはAIONのマイクロサービスで利用するpythonライブラリーです。 3 | 4 | ## 動作環境 5 | aion-related-python-libraryは、AIONのプラットフォーム上での動作を前提としています。 6 | 使用する際は、事前に以下の動作環境を用意してください。 7 | 8 | ・OS: Linux Ubuntu 9 | ・CPU: ARM/AMD/Intel 10 | ・Kubernetes 11 | ・AIONのリソース 12 | 13 | ## 概要 14 | aion-related-python-library内のaionディレクトリ以下にライブラリーが含まれています。 15 | ``` 16 | kanban: 17 | kanbanサーバーへの問い合わせ 18 | kanbanサーバーへの書き込み 19 | redisクライアントの生成 20 | logger: 21 | k8sにログを吐き出せる 22 | k8s対応を行ったデバッグログのラッパー 23 | microservice: 24 | 内部で実装しているdecoratorを実装している。 25 | decoratorを呼び出したマイクロサービスをkanbanクライアント化する 26 | mongo: 27 | mongoクライアントの生成 28 | mongoへの問い合わせ 29 | mongoへのデータ書き込み 30 | mysql: 31 | mysqlクライアントの生成 32 | mysqlへの問い合わせ 33 | mysqlへのデータ書き込み 34 | proto: 35 | 自動生成されたgrpcのコードが入っている 36 | kanbanライブラリでのgrpcに使用 37 | ``` 38 | 39 | ## 利用方法 40 | このリポジトリをクローンし、カレントディレクトリにしてください。その後、以下の手順でコンテナにマウントし、ライブラリーをインストールしてください。 41 | ``` 42 | $ docker exec -it [コンテナ名] bash #コンテナに入る 43 | $ apt-get install python3-dev libmysqlclient-dev #mysql_config: not foundエラーの対策 44 | $ cd ~/path/to/aion-related-python-library 45 | $ pip install . 46 | ``` 47 | Dockerfileや、docker-compose.ymlに記載して使用する方法は、testディレクトリ配下のファイルを参照してください。 48 | 49 | 50 | -------------------------------------------------------------------------------- /aion/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | __all__ = ["kanban", "logger", "microservice", "proto"] 6 | 7 | from aion import * -------------------------------------------------------------------------------- /aion/kanban/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | __all__ = ["kanban","async_kanban"] 6 | 7 | from .kanban import KanbanConnection, KanbanNotFoundError, KanbanServerNotFoundError, Kanban 8 | 9 | from .async_kanban import KanbanConnectionAsync 10 | -------------------------------------------------------------------------------- /aion/kanban/async_kanban.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | from aion.proto import status_pb2_grpc as rpc 6 | from aion.proto import status_pb2 as message 7 | import grpc 8 | from grpc.experimental import aio 9 | from google.protobuf.any_pb2 import Any 10 | from google.protobuf.struct_pb2 import Struct 11 | from google.protobuf.json_format import MessageToDict 12 | 13 | from threading import Thread, Condition 14 | from asyncio import Queue, wait_for, TimeoutError, get_event_loop, ensure_future 15 | from dateutil import parser 16 | from typing import Iterator 17 | 18 | from aion.logger import lprint 19 | from .kanban import KanbanConnection 20 | 21 | async def _grpc_message_generator(message_queue): 22 | while True: 23 | try: 24 | r = await message_queue.get() 25 | if r is None: 26 | break 27 | yield r 28 | except TimeoutError: 29 | lprint("send queue is closed") 30 | break 31 | 32 | 33 | class Kanban: 34 | def __init__(self, kanban): 35 | self.kanban = kanban 36 | 37 | def get_start_at(self): 38 | if self.kanban.startAt: 39 | return parser.parse(self.kanban.startAt) 40 | return None 41 | 42 | def get_finish_at(self): 43 | if self.kanban.startAt: 44 | return parser.parse(self.kanban.finishAt) 45 | return None 46 | 47 | def get_services(self): 48 | return self.kanban.services 49 | 50 | def get_connection_key(self): 51 | return self.kanban.connectionKey 52 | 53 | def get_process_number(self): 54 | return self.kanban.processNumber 55 | 56 | def get_result(self): 57 | return self.kanban.priorSuccess 58 | 59 | def get_data_path(self): 60 | return self.kanban.dataPath 61 | 62 | def get_file_list(self): 63 | return self.kanban.fileList 64 | 65 | def get_metadata(self): 66 | return MessageToDict(self.kanban.metadata) 67 | 68 | 69 | class KanbanServerNotFoundError(Exception): 70 | def __init__(self, addr): 71 | self.addr = addr 72 | 73 | def __str__(self): 74 | return f"cant connect to kanban server: {self.addr}" 75 | 76 | 77 | class KanbanNotFoundError(Exception): 78 | def __init__(self): 79 | pass 80 | 81 | def __str__(self): 82 | return f"cant get kanban from server" 83 | 84 | 85 | class _Callback(object): 86 | def __init__(self): 87 | self._condition = Condition() 88 | self._connectivity = None 89 | 90 | def update(self, connectivity): 91 | with self._condition: 92 | self._connectivity = connectivity 93 | self._condition.notify() 94 | 95 | def connectivity(self): 96 | with self._condition: 97 | return self._connectivity 98 | 99 | def block_until_connectivities_satisfy(self, predicate): 100 | with self._condition: 101 | while True: 102 | connectivity = self._connectivity 103 | if predicate(connectivity): 104 | return connectivity 105 | else: 106 | self._condition.wait() 107 | 108 | 109 | class KanbanConnectionAsync(KanbanConnection): 110 | channel = None 111 | conn = None 112 | response_thread = None 113 | 114 | def __init__(self, addr="localhost:11010"): 115 | self.addr = addr 116 | loop = get_event_loop() 117 | loop.run_until_complete(self.run()) 118 | 119 | async def run(self): 120 | aio.init_grpc_aio() 121 | self.channel = aio.insecure_channel(self.addr) 122 | await self.channel.channel_ready() 123 | self.connectivity = self.channel.get_state(try_to_connect=True) 124 | 125 | self.conn = rpc.KanbanStub(self.channel) 126 | 127 | self.send_kanban_queue = Queue() 128 | self.recv_kanban_queue = Queue() 129 | 130 | self.responses = self.conn.MicroserviceConn(_grpc_message_generator(self.send_kanban_queue)) 131 | 132 | self.check_connectivity() 133 | self.is_thread_stop = False 134 | self.response_thread = ensure_future(self._receive_function()) 135 | 136 | def reconnect(self): 137 | loop = get_event_loop() 138 | loop.run_until_complete(self.run()) 139 | self.check_connectivity() 140 | if self.current_message_type == message.START_SERVICE_WITHOUT_KANBAN: 141 | self.set_kanban(self.current_service_name, self.current_number) 142 | else: 143 | self._send_initial_kanban(message.START_SERVICE, self.current_service_name, self.current_number) 144 | 145 | def set_current_service_name(self, service_name): 146 | self.current_service_name = service_name 147 | 148 | def set_current_number(self, number): 149 | self.current_number = number 150 | 151 | def set_current_message_type(self, messate_type): 152 | self.current_message_type = messate_type 153 | 154 | def check_connectivity(self): 155 | lprint(self.connectivity) 156 | if grpc.ChannelConnectivity.READY != self.connectivity: 157 | raise KanbanServerNotFoundError(self.addr) 158 | 159 | async def close(self, complete=False): 160 | self.is_thread_stop = True 161 | connection_key = '' 162 | if complete: 163 | connection_key = 'service-broker' 164 | await self.output_kanban( 165 | process_number = self.current_number, 166 | connection_key = connection_key, 167 | result = complete, 168 | metadata = { 169 | "type": "terminate", 170 | "name": self.current_service_name, 171 | "number": self.current_number 172 | } 173 | ) 174 | await self.send_kanban_queue.put(None) 175 | await self.channel.close() 176 | if self.response_thread is not None: 177 | self.response_thread.cancel() 178 | 179 | async def _receive_function(self): 180 | try: 181 | async for res in self.responses: 182 | if res.messageType == message.RES_CACHE_KANBAN: 183 | if res.error != "": 184 | lprint(f"[gRPC] get cache kanban is failed :{res.error}") 185 | await self.recv_kanban_queue.put(None) 186 | else: 187 | await self.recv_kanban_queue.put(res.message) 188 | elif res.messageType == message.RES_REQUEST_RESULT: 189 | if res.error != "": 190 | lprint(f"[gRPC] request is failed :{res.error}") 191 | else: 192 | lprint(f"[gRPC] success to send request :{res.messageType}") 193 | else: 194 | lprint(f"[gRPC] invalid message type: {res.messageType}") 195 | except grpc.RpcError as e: 196 | await self.recv_kanban_queue.put(None) 197 | 198 | lprint(f'[gRPC] failed with code {e.code()}') 199 | if e.code() == grpc.StatusCode.CANCELLED: 200 | if self.is_thread_stop: 201 | lprint("[gRPC] closed connection is successful") 202 | else: 203 | self.reconnect() 204 | elif e.code() == grpc.StatusCode.INTERNAL: 205 | # when stream idle time is more than 5 minutes, grpc connection is disconnected by envoy. 206 | # while that action is not wrong(long live connection is evil), it is bother by application. 207 | # so we attempt to reconnect on library. 208 | self.reconnect() 209 | 210 | async def _send_message_to_grpc(self, req): 211 | await self.send_kanban_queue.put(req) 212 | 213 | async def _send_initial_kanban(self, message_type, service_name, number): 214 | m = message.InitializeService() 215 | m.microserviceName = service_name 216 | m.processNumber = int(number) 217 | req = message.Request() 218 | req.initMessage.CopyFrom(m) 219 | await self._send_message_to_grpc(req) 220 | 221 | async def get_one_kanban(self, service_name, number) -> Kanban: 222 | self._send_initial_kanban(message.START_SERVICE, service_name, number) 223 | 224 | self.set_current_service_name(service_name) 225 | self.set_current_number(number) 226 | self.set_current_message_type(message.START_SERVICE) 227 | # get kanban when 228 | k = None 229 | try: 230 | k = await wait_for(self.recv_kanban_queue.get(), timeout=0.1) 231 | except TimeoutError: 232 | lprint("[gRPC] cant connect to status kanban server, exit service") 233 | if k is None: 234 | raise KanbanNotFoundError 235 | 236 | return Kanban(k) 237 | 238 | async def get_kanban_itr(self, service_name: str, number: int) -> Iterator[Kanban]: 239 | await self._send_initial_kanban(message.START_SERVICE, service_name, number) 240 | 241 | self.set_current_service_name(service_name) 242 | self.set_current_number(number) 243 | self.set_current_message_type(message.START_SERVICE) 244 | # get kanban when 245 | k = None 246 | try: 247 | while True: 248 | k = await self.recv_kanban_queue.get() 249 | if k is None: 250 | break 251 | yield Kanban(k) 252 | except TimeoutError: 253 | lprint("[gRPC] kanban queue is empty") 254 | 255 | async def set_kanban(self, service_name, number) -> Kanban: 256 | self._send_initial_kanban(message.START_SERVICE_WITHOUT_KANBAN, service_name, number) 257 | 258 | self.set_current_service_name(service_name) 259 | self.set_current_number(number) 260 | self.set_current_message_type(message.START_SERVICE_WITHOUT_KANBAN) 261 | # get kanban when 262 | k = None 263 | try: 264 | k = await wait_for(self.recv_kanban_queue.get(), timeout=0.1) 265 | except TimeoutError: 266 | lprint("[gRPC] cant connect to status kanban server, exit service") 267 | if k is None: 268 | raise KanbanNotFoundError 269 | 270 | return Kanban(k) 271 | 272 | async def output_kanban( 273 | self, result=True, connection_key="default", output_data_path="", 274 | process_number=1, file_list=None, metadata=None, device_name="") -> None: 275 | m = message.OutputRequest() 276 | 277 | if metadata is None: 278 | metadata = {} 279 | 280 | if not file_list: 281 | file_list = [] 282 | elif not isinstance(file_list, list): 283 | file_list = [file_list] 284 | 285 | s = Struct() 286 | s.update(metadata) 287 | 288 | m.priorSuccess = result 289 | m.dataPath = output_data_path 290 | m.connectionKey = connection_key 291 | m.processNumber = int(process_number) 292 | m.fileList.extend(file_list) 293 | m.metadata.CopyFrom(s) 294 | m.nextDeviceName = device_name 295 | req = message.Request() 296 | req.message.CopyFrom(m) 297 | self._send_message_to_grpc(req) 298 | 299 | -------------------------------------------------------------------------------- /aion/kanban/kanban.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | import grpc 6 | from threading import Thread, Condition 7 | from queue import Queue, Empty 8 | from dateutil import parser 9 | from typing import Iterator 10 | from retry import retry 11 | 12 | from google.protobuf.any_pb2 import Any 13 | from google.protobuf.struct_pb2 import Struct 14 | from google.protobuf.json_format import MessageToDict 15 | 16 | from aion.logger import lprint 17 | from aion.proto import status_pb2_grpc as rpc 18 | from aion.proto import status_pb2 as message 19 | 20 | 21 | class Kanban: 22 | def __init__(self, kanban): 23 | self.kanban = kanban 24 | 25 | def get_start_at(self): 26 | if self.kanban.startAt: 27 | return parser.parse(self.kanban.startAt) 28 | return None 29 | 30 | def get_finish_at(self): 31 | if self.kanban.startAt: 32 | return parser.parse(self.kanban.finishAt) 33 | return None 34 | 35 | def get_services(self): 36 | return self.kanban.services 37 | 38 | def get_connection_key(self): 39 | return self.kanban.connectionKey 40 | 41 | def get_process_number(self): 42 | return self.kanban.processNumber 43 | 44 | def get_result(self): 45 | return self.kanban.priorSuccess 46 | 47 | def get_data_path(self): 48 | return self.kanban.dataPath 49 | 50 | def get_file_list(self): 51 | return self.kanban.fileList 52 | 53 | def get_metadata(self): 54 | return MessageToDict(self.kanban.metadata) 55 | 56 | 57 | class KanbanServerNotFoundError(Exception): 58 | def __init__(self, addr): 59 | self.addr = addr 60 | 61 | def __str__(self): 62 | return f"cant connect to kanban server: {self.addr}" 63 | 64 | 65 | class KanbanNotFoundError(Exception): 66 | def __init__(self): 67 | pass 68 | 69 | def __str__(self): 70 | return f"cant get kanban from server" 71 | 72 | 73 | class _Callback(object): 74 | def __init__(self): 75 | self._condition = Condition() 76 | self._connectivity = None 77 | 78 | def update(self, connectivity): 79 | with self._condition: 80 | self._connectivity = connectivity 81 | self._condition.notify() 82 | 83 | def connectivity(self): 84 | with self._condition: 85 | return self._connectivity 86 | 87 | def block_until_connectivities_satisfy(self, predicate): 88 | with self._condition: 89 | while True: 90 | connectivity = self._connectivity 91 | if predicate(connectivity): 92 | return connectivity 93 | else: 94 | self._condition.wait() 95 | 96 | 97 | class KanbanConnection: 98 | 99 | def __init__(self, addr, init_type, service_name, process_number): 100 | self.addr = addr 101 | self.init_type = init_type 102 | self.service_name = service_name 103 | self.process_number = process_number 104 | self.recv_kanban_queue = Queue() 105 | self.run() 106 | 107 | def run(self): 108 | try: 109 | callback = _Callback() 110 | self.channel = grpc.insecure_channel(self.addr) 111 | self.channel = grpc.insecure_channel(self.addr, options=[('grpc.keepalive_time_ms', 20000), ('grpc.keepalive_timeout_ms', 60000), ('grpc.min_time_between_pings_ms', 120000), ('grpc.max_pings_without_data', 0)]) 112 | self.channel.subscribe(callback.update, try_to_connect=True) 113 | self.connectivity = callback.block_until_connectivities_satisfy( 114 | lambda c: 115 | c == grpc.ChannelConnectivity.READY or 116 | c == grpc.ChannelConnectivity.TRANSIENT_FAILURE 117 | ) 118 | self.recv_conn = rpc.KanbanStub(self.channel) 119 | self.responses = self.recv_conn.ReceiveKanban(message.InitializeService( 120 | initType=self.init_type, 121 | microserviceName=self.service_name, 122 | processNumber=self.process_number 123 | )) 124 | 125 | #self.send_channel = grpc.insecure_channel(self.addr) 126 | self.send_conn = rpc.KanbanStub(self.channel) 127 | 128 | self.check_connectivity() 129 | self.is_thread_stop = False 130 | self.response_thread = Thread(target=self._receive_function, args=()) 131 | self.response_thread.start() 132 | lprint("start watch kanban") 133 | except Exception as e: 134 | raise e 135 | 136 | @retry(exceptions=Exception, tries=5, delay=1, backoff=2, max_delay=4) 137 | def reconnect(self): 138 | try: 139 | lprint("[gRPC] reconnect connection") 140 | self.run() 141 | except Exception as e: 142 | raise e 143 | 144 | def check_connectivity(self): 145 | lprint(self.connectivity) 146 | if grpc.ChannelConnectivity.READY != self.connectivity: 147 | raise KanbanServerNotFoundError(self.addr) 148 | 149 | def close(self, complete=False): 150 | self.is_thread_stop = True 151 | self.recv_kanban_queue.put(None) 152 | connection_key = '' 153 | if complete: 154 | connection_key = 'service-broker' 155 | self.output_kanban( 156 | process_number = self.process_number, 157 | connection_key = connection_key, 158 | result = complete, 159 | metadata = { 160 | "type": "terminate", 161 | "name": self.service_name, 162 | "number": self.process_number 163 | } 164 | ) 165 | if self.response_thread is not None: 166 | self.response_thread.join() 167 | lprint("[gRPC] stop microservice") 168 | 169 | def _receive_function(self): 170 | try: 171 | for res in self.responses: 172 | lprint("[gRPC] get cache kanban") 173 | self.recv_kanban_queue.put(res) 174 | except Exception as e: 175 | self.responses.cancel() 176 | self.channel.close() 177 | lprint(f'[gRPC] exception caused: {e}') 178 | if self.is_thread_stop: 179 | lprint("[gRPC] closed connection is successful") 180 | else: 181 | self.reconnect() 182 | 183 | def get_one_kanban(self) -> Kanban: 184 | try: 185 | k = self.recv_kanban_queue.get() 186 | if k is None: 187 | raise KanbanNotFoundError 188 | except Empty: 189 | lprint("[gRPC] cant connect to status kanban server, exit service") 190 | 191 | return Kanban(k) 192 | 193 | def get_kanban_itr(self) -> Iterator[Kanban]: 194 | try: 195 | while True: 196 | k = self.recv_kanban_queue.get() 197 | if k is None: 198 | break 199 | yield Kanban(k) 200 | except Empty: 201 | lprint("[gRPC] kanban queue is empty") 202 | 203 | def output_kanban( 204 | self, result=True, connection_key="default", output_data_path="", 205 | process_number=1, file_list=None, metadata=None, device_name="") -> None: 206 | m = message.StatusKanban() 207 | 208 | if metadata is None: 209 | metadata = {} 210 | 211 | if not file_list: 212 | file_list = [] 213 | elif not isinstance(file_list, list): 214 | file_list = [file_list] 215 | 216 | s = Struct() 217 | s.update(metadata) 218 | 219 | m.priorSuccess = result 220 | m.dataPath = output_data_path 221 | m.connectionKey = connection_key 222 | m.processNumber = int(process_number) 223 | m.fileList.extend(file_list) 224 | m.metadata.CopyFrom(s) 225 | m.nextDeviceName = device_name 226 | 227 | self.send_conn.SendKanban(message.Request( 228 | microserviceName=self.service_name, 229 | message=m 230 | )) 231 | lprint("[gRPC] send message to status-kanban") 232 | 233 | -------------------------------------------------------------------------------- /aion/logger/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | __all__ = ["looger"] 6 | 7 | from aion.logger.logger import initialize_logger, function_log, lprint, lprint_exception 8 | -------------------------------------------------------------------------------- /aion/logger/logger.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | import asyncio 6 | from time import time 7 | from logging import basicConfig, getLogger, DEBUG 8 | 9 | component_name = "None" 10 | logger = None 11 | 12 | 13 | def initialize_logger(component, level=DEBUG): 14 | global component_name 15 | global logger 16 | component_name = component 17 | basicConfig( 18 | format='%(asctime)s000 - %(levelname)-4s - %(process)-5d - %(name)s - %(message)s', 19 | level=level, 20 | ) 21 | logger = getLogger(component_name) 22 | 23 | 24 | def lprint(*args): 25 | global logger 26 | message = ", ".join([str(x) for x in args]) 27 | logger.debug(message) 28 | 29 | 30 | def lprint_exception(e): 31 | logger.exception(f'{e}') 32 | 33 | 34 | def function_log(func): 35 | if asyncio.iscoroutinefunction(func): 36 | async def async_wrapper(*args, **kwargs): 37 | func_name = func.__name__ 38 | st = time() 39 | # start log 40 | lprint("Start: " + func_name) 41 | res = await func(*args, **kwargs) 42 | # finish log 43 | lprint("Finish:" + func_name + "(time:{})".format(time() - st)) 44 | return res 45 | 46 | return async_wrapper 47 | else: 48 | def wrapper(*args, **kwargs): 49 | func_name = func.__name__ 50 | st = time() 51 | # start log 52 | lprint("Start: " + func_name) 53 | res = func(*args, **kwargs) 54 | # finish log 55 | lprint("Finish:" + func_name + "(time:{})".format(time() - st)) 56 | return res 57 | 58 | return wrapper 59 | -------------------------------------------------------------------------------- /aion/microservice/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | __all__ = ["microservice"] 6 | 7 | from aion.microservice.microservice import main_decorator, Options, WITH_KANBAN, WITHOUT_KANBAN 8 | -------------------------------------------------------------------------------- /aion/microservice/microservice.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | from aion.logger import initialize_logger, lprint_exception, lprint 6 | from aion.kanban import KanbanConnection, KanbanConnectionAsync, KanbanServerNotFoundError 7 | from aion.proto import status_pb2 as message 8 | from logging import DEBUG 9 | import os 10 | from retry import retry 11 | 12 | NORMAL_CONNECTION_MODE = "normal" 13 | DIRECT_CONNECTION_MODE = "direct" 14 | 15 | WITH_KANBAN = True 16 | WITHOUT_KANBAN = False 17 | 18 | 19 | class Options: 20 | conn: KanbanConnection 21 | ms_number: int 22 | docker: bool 23 | 24 | def __init__(self, conn: KanbanConnection, ms_number: int, is_docker: bool): 25 | self.conn = conn 26 | self.ms_number = ms_number 27 | self.docker = is_docker 28 | 29 | def get_conn(self) -> KanbanConnection: 30 | return self.conn 31 | 32 | def get_number(self) -> int: 33 | return self.ms_number 34 | 35 | def is_docker(self) -> bool: 36 | return self.docker 37 | 38 | 39 | def main_decorator(service_name, init_type, level=DEBUG, async_kanban=False): 40 | initialize_logger(service_name, level) 41 | 42 | def _main_decorator(func): 43 | 44 | @retry(exceptions=Exception, tries=5, delay=1, backoff=2, max_delay=4) 45 | def _wrapper(*args, **kwargs): 46 | conn = None 47 | try: 48 | addr = os.environ.get("KANBAN_ADDR") 49 | n = os.environ.get("MS_NUMBER") 50 | n = int(n) if n else 1 51 | 52 | connection_mode = os.environ.get("CONNECTION_MODE", NORMAL_CONNECTION_MODE) 53 | if connection_mode == DIRECT_CONNECTION_MODE: 54 | addr = "aion-statuskanban:10000" 55 | 56 | if init_type == WITH_KANBAN: 57 | init_msg_type = message.START_SERVICE 58 | else: 59 | init_msg_type = message.START_SERVICE_WITHOUT_KANBAN 60 | 61 | if async_kanban: 62 | conn = KanbanConnectionAsync(addr) if addr else KanbanConnectionAsync() 63 | else: 64 | conn = KanbanConnection(addr, init_msg_type, service_name, n) if addr else KanbanConnection("aion-statuskanban:11010", init_msg_type, service_name, n) 65 | 66 | docker = os.environ.get("IS_DOCKER") 67 | is_docker = True if docker else False 68 | 69 | options = Options( 70 | conn=conn, 71 | ms_number=n, 72 | is_docker=is_docker, 73 | ) 74 | func(*args, **kwargs, opt=options) 75 | if conn is not None: 76 | conn.close(complete=True) 77 | except Exception as e: 78 | lprint_exception(e) 79 | if conn is not None: 80 | conn.close() 81 | raise 82 | return 83 | return _wrapper 84 | return _main_decorator 85 | -------------------------------------------------------------------------------- /aion/mongo/__init__.py: -------------------------------------------------------------------------------- 1 | from .query import * 2 | -------------------------------------------------------------------------------- /aion/mongo/query.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | import os 6 | import traceback 7 | 8 | from pymongo import MongoClient 9 | from aion.logger import lprint 10 | 11 | 12 | class BaseMongoAccess(): 13 | def __init__(self, db_name): 14 | self._db_name = db_name 15 | 16 | def __enter__(self): 17 | self.client = MongoClient( 18 | port=int(os.environ.get('MONGO_SERVICE_PORT')), 19 | host=os.environ.get('MONGO_SERVICE_HOST')) 20 | self._db = self.client[self._db_name] 21 | return self 22 | 23 | def __exit__(self, exc_type, exc_value, tb): 24 | if exc_type is not None: 25 | for message in traceback.format_exception(exc_type, exc_value, tb): 26 | lprint(message.rstrip('\n')) 27 | if self.client: 28 | self.client.close() 29 | return True 30 | 31 | def create_index(self, collection, key, index_type): 32 | collect = self._db.get_collection(collection) 33 | if collect is None: 34 | return False 35 | index = [(key, index_type)] 36 | collect.create_index(index) 37 | return True 38 | 39 | def find(self, collection, projection=None, filter=None, sort=None): 40 | collect = self._db.get_collection(collection) 41 | if collect is None: 42 | return False 43 | return collect.find(projection=projection, filter=filter, sort=sort) 44 | 45 | def insert_many(self, collection, data): 46 | if not isinstance(data, list): 47 | return False 48 | collect = self._db.get_collection(collection) 49 | if collect is None: 50 | return False 51 | collect.insert_many(data) 52 | return True 53 | 54 | def insert_one(self, collection, data): 55 | if not isinstance(data, dict): 56 | return False 57 | collect = self._db.get_collection(collection) 58 | if collect is None: 59 | return False 60 | collect.insert_one(data) 61 | return True 62 | 63 | def delete_one(self, collection, filter): 64 | collect = self._db.get_collection(collection) 65 | if collect is None: 66 | return False 67 | result = collect.delete_one(filter) 68 | deleted_count = result.deleted_count 69 | return deleted_count 70 | 71 | def delete_many(self, collection, filter): 72 | collect = self._db.get_collection(collection) 73 | if collect is None: 74 | return False 75 | result = collect.delete_many(filter) 76 | deleted_count = result.deleted_count 77 | return deleted_count 78 | 79 | def drop(self, collection): 80 | collect = self._db.get_collection(collection) 81 | if collect is None: 82 | return False 83 | collect.drop() 84 | return 85 | 86 | def is_connect(self): 87 | return bool(self.cursor) 88 | -------------------------------------------------------------------------------- /aion/mysql/__init__.py: -------------------------------------------------------------------------------- 1 | from .query import * 2 | -------------------------------------------------------------------------------- /aion/mysql/install_amd.sh: -------------------------------------------------------------------------------- 1 | apt update -y 2 | apt install -y libmariadb-dev-compat libmariadb-dev 3 | apt install -y libssl-dev zlib1g-dev gcc g++ make 4 | apt clean 5 | rm -rf /var/lib/apt/lists/* 6 | git clone https://github.com/edenhill/librdkafka 7 | cd librdkafka 8 | ./configure --prefix=/usr 9 | make 10 | make install 11 | cd .. 12 | rm -rf librdkafka 13 | pip3 install mysqlclient 14 | -------------------------------------------------------------------------------- /aion/mysql/query.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | import os 6 | import traceback 7 | 8 | import MySQLdb 9 | from aion.logger import lprint, lprint_exception 10 | 11 | 12 | class BaseMysqlAccess(): 13 | cursor = None 14 | default_mysql_host = "mysql" 15 | default_mysql_port = "3306" 16 | default_mysql_user = "latona" 17 | 18 | def __init__(self, db_name): 19 | self._db_name = db_name 20 | 21 | def __enter__(self): 22 | try: 23 | self.connection = MySQLdb.connect( 24 | host=os.environ.get('MY_MYSQL_HOST', self.default_mysql_host), 25 | port=int(os.environ.get('MY_MYSQL_PORT', self.default_mysql_port)), 26 | user=os.environ.get('MYSQL_USER', self.default_mysql_user), 27 | passwd=os.environ.get('MYSQL_PASSWORD'), 28 | db=self._db_name, 29 | charset='utf8') 30 | self.cursor = self.connection.cursor(MySQLdb.cursors.DictCursor) 31 | except MySQLdb.Error as e: 32 | lprint("cant connect mysql") 33 | lprint_exception(e) 34 | self.cursor = None 35 | raise e 36 | return self 37 | 38 | def __exit__(self, exc_type, exc_value, tb): 39 | if exc_type is not None: 40 | for message in traceback.format_exception(exc_type, exc_value, tb): 41 | lprint(message.rstrip('\n')) 42 | if self.cursor: 43 | self.cursor.close() 44 | self.connection.close() 45 | return True 46 | 47 | def get_query(self, sql, args=None): 48 | if not self.cursor: 49 | return None 50 | self.cursor.execute(sql, args) 51 | return self.cursor.fetchone() 52 | 53 | def get_query_list(self, size, sql, args=None): 54 | if not self.cursor: 55 | return None 56 | self.cursor.execute(sql, args) 57 | return self.cursor.fetchmany(size) 58 | 59 | def set_query(self, sql, args=None): 60 | if not self.cursor: 61 | return False 62 | self.cursor.execute(sql, args) 63 | return True 64 | 65 | def commit_query(self): 66 | self.connection.commit() 67 | 68 | def is_connect(self): 69 | return bool(self.cursor) 70 | -------------------------------------------------------------------------------- /aion/proto/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # Copyright (c) 2019-2020 Latona. All rights reserved. 4 | 5 | __all__ = ["status_pb2_grpc", "status_pb2"] 6 | 7 | from . import * 8 | -------------------------------------------------------------------------------- /aion/proto/status_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: proto/kanbanpb/status.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import enum_type_wrapper 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import message as _message 8 | from google.protobuf import reflection as _reflection 9 | from google.protobuf import symbol_database as _symbol_database 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2 16 | from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 17 | 18 | 19 | DESCRIPTOR = _descriptor.FileDescriptor( 20 | name='proto/kanbanpb/status.proto', 21 | package='kanbanpb', 22 | syntax='proto3', 23 | serialized_options=b'Z/bitbucket.org/latonaio/aion-core/proto/kanbanpb', 24 | create_key=_descriptor._internal_create_key, 25 | serialized_pb=b'\n\x1bproto/kanbanpb/status.proto\x12\x08kanbanpb\x1a\x1cgoogle/protobuf/struct.proto\x1a\x19google/protobuf/any.proto\"\xdc\x01\n\x0cStatusKanban\x12\x0f\n\x07startAt\x18\x01 \x01(\t\x12\x10\n\x08\x66inishAt\x18\x02 \x01(\t\x12\x16\n\x0enextDeviceName\x18\x03 \x01(\t\x12\x15\n\rconnectionKey\x18\x04 \x01(\t\x12\x15\n\rprocessNumber\x18\x05 \x01(\x05\x12\x14\n\x0cpriorSuccess\x18\x06 \x01(\x08\x12\x10\n\x08\x64\x61taPath\x18\x07 \x01(\t\x12\x10\n\x08\x66ileList\x18\x08 \x03(\t\x12)\n\x08metadata\x18\t \x01(\x0b\x32\x17.google.protobuf.Struct\"\x8a\x01\n\nSendKanban\x12\x12\n\ndeviceName\x18\x01 \x01(\t\x12\x12\n\ndeviceAddr\x18\x02 \x01(\t\x12\x13\n\x0bnextService\x18\x03 \x01(\t\x12\x12\n\nnextNumber\x18\x04 \x01(\x05\x12+\n\x0b\x61\x66terKanban\x18\x05 \x01(\x0b\x32\x16.kanbanpb.StatusKanban\"&\n\x05\x43hunk\x12\x0f\n\x07\x63ontext\x18\x01 \x01(\x0c\x12\x0c\n\x04name\x18\x02 \x01(\t\"_\n\x0bSendContext\x12)\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x1b.kanbanpb.UploadRequestCode\x12%\n\x07\x63ontext\x18\x02 \x01(\x0b\x32\x14.google.protobuf.Any\"O\n\x0cUploadStatus\x12\x0f\n\x07Message\x18\x01 \x01(\t\x12.\n\nstatusCode\x18\x02 \x01(\x0e\x32\x1a.kanbanpb.UploadStatusCode\"p\n\x11InitializeService\x12*\n\x08initType\x18\x01 \x01(\x0e\x32\x18.kanbanpb.InitializeType\x12\x18\n\x10microserviceName\x18\x02 \x01(\t\x12\x15\n\rprocessNumber\x18\x03 \x01(\x05\"L\n\x07Request\x12\x18\n\x10microserviceName\x18\x01 \x01(\t\x12\'\n\x07message\x18\x02 \x01(\x0b\x32\x16.kanbanpb.StatusKanban\"C\n\x08Response\x12(\n\x06status\x18\x01 \x01(\x0e\x32\x18.kanbanpb.ResponseStatus\x12\r\n\x05\x65rror\x18\x02 \x01(\t*r\n\x11UploadRequestCode\x12\x11\n\rSendingKanban\x10\x00\x12\x14\n\x10SendingFile_CONT\x10\x01\x12\x13\n\x0fSendingFile_EOF\x10\x02\x12\x16\n\x12SendingFile_FAILED\x10\x03\x12\x07\n\x03\x45OS\x10\x04*3\n\x10UploadStatusCode\x12\x0b\n\x07Unknown\x10\x00\x12\n\n\x06\x46\x61iled\x10\x01\x12\x06\n\x02OK\x10\x02*E\n\x0eInitializeType\x12\x11\n\rSTART_SERVICE\x10\x00\x12 \n\x1cSTART_SERVICE_WITHOUT_KANBAN\x10\x01*)\n\x0eResponseStatus\x12\x0b\n\x07SUCCESS\x10\x00\x12\n\n\x06\x46\x41ILED\x10\x01\x32\x85\x01\n\x06Kanban\x12\x46\n\rReceiveKanban\x12\x1b.kanbanpb.InitializeService\x1a\x16.kanbanpb.StatusKanban0\x01\x12\x33\n\nSendKanban\x12\x11.kanbanpb.Request\x1a\x12.kanbanpb.Response2\x9a\x01\n\x0cSendAnything\x12\x43\n\x11ServiceBrokerConn\x12\x14.kanbanpb.SendKanban\x1a\x14.kanbanpb.SendKanban(\x01\x30\x01\x12\x45\n\x12SendToOtherDevices\x12\x15.kanbanpb.SendContext\x1a\x16.kanbanpb.UploadStatus(\x01\x42\x31Z/bitbucket.org/latonaio/aion-core/proto/kanbanpbb\x06proto3' 26 | , 27 | dependencies=[google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_protobuf_dot_any__pb2.DESCRIPTOR,]) 28 | 29 | _UPLOADREQUESTCODE = _descriptor.EnumDescriptor( 30 | name='UploadRequestCode', 31 | full_name='kanbanpb.UploadRequestCode', 32 | filename=None, 33 | file=DESCRIPTOR, 34 | create_key=_descriptor._internal_create_key, 35 | values=[ 36 | _descriptor.EnumValueDescriptor( 37 | name='SendingKanban', index=0, number=0, 38 | serialized_options=None, 39 | type=None, 40 | create_key=_descriptor._internal_create_key), 41 | _descriptor.EnumValueDescriptor( 42 | name='SendingFile_CONT', index=1, number=1, 43 | serialized_options=None, 44 | type=None, 45 | create_key=_descriptor._internal_create_key), 46 | _descriptor.EnumValueDescriptor( 47 | name='SendingFile_EOF', index=2, number=2, 48 | serialized_options=None, 49 | type=None, 50 | create_key=_descriptor._internal_create_key), 51 | _descriptor.EnumValueDescriptor( 52 | name='SendingFile_FAILED', index=3, number=3, 53 | serialized_options=None, 54 | type=None, 55 | create_key=_descriptor._internal_create_key), 56 | _descriptor.EnumValueDescriptor( 57 | name='EOS', index=4, number=4, 58 | serialized_options=None, 59 | type=None, 60 | create_key=_descriptor._internal_create_key), 61 | ], 62 | containing_type=None, 63 | serialized_options=None, 64 | serialized_start=941, 65 | serialized_end=1055, 66 | ) 67 | _sym_db.RegisterEnumDescriptor(_UPLOADREQUESTCODE) 68 | 69 | UploadRequestCode = enum_type_wrapper.EnumTypeWrapper(_UPLOADREQUESTCODE) 70 | _UPLOADSTATUSCODE = _descriptor.EnumDescriptor( 71 | name='UploadStatusCode', 72 | full_name='kanbanpb.UploadStatusCode', 73 | filename=None, 74 | file=DESCRIPTOR, 75 | create_key=_descriptor._internal_create_key, 76 | values=[ 77 | _descriptor.EnumValueDescriptor( 78 | name='Unknown', index=0, number=0, 79 | serialized_options=None, 80 | type=None, 81 | create_key=_descriptor._internal_create_key), 82 | _descriptor.EnumValueDescriptor( 83 | name='Failed', index=1, number=1, 84 | serialized_options=None, 85 | type=None, 86 | create_key=_descriptor._internal_create_key), 87 | _descriptor.EnumValueDescriptor( 88 | name='OK', index=2, number=2, 89 | serialized_options=None, 90 | type=None, 91 | create_key=_descriptor._internal_create_key), 92 | ], 93 | containing_type=None, 94 | serialized_options=None, 95 | serialized_start=1057, 96 | serialized_end=1108, 97 | ) 98 | _sym_db.RegisterEnumDescriptor(_UPLOADSTATUSCODE) 99 | 100 | UploadStatusCode = enum_type_wrapper.EnumTypeWrapper(_UPLOADSTATUSCODE) 101 | _INITIALIZETYPE = _descriptor.EnumDescriptor( 102 | name='InitializeType', 103 | full_name='kanbanpb.InitializeType', 104 | filename=None, 105 | file=DESCRIPTOR, 106 | create_key=_descriptor._internal_create_key, 107 | values=[ 108 | _descriptor.EnumValueDescriptor( 109 | name='START_SERVICE', index=0, number=0, 110 | serialized_options=None, 111 | type=None, 112 | create_key=_descriptor._internal_create_key), 113 | _descriptor.EnumValueDescriptor( 114 | name='START_SERVICE_WITHOUT_KANBAN', index=1, number=1, 115 | serialized_options=None, 116 | type=None, 117 | create_key=_descriptor._internal_create_key), 118 | ], 119 | containing_type=None, 120 | serialized_options=None, 121 | serialized_start=1110, 122 | serialized_end=1179, 123 | ) 124 | _sym_db.RegisterEnumDescriptor(_INITIALIZETYPE) 125 | 126 | InitializeType = enum_type_wrapper.EnumTypeWrapper(_INITIALIZETYPE) 127 | _RESPONSESTATUS = _descriptor.EnumDescriptor( 128 | name='ResponseStatus', 129 | full_name='kanbanpb.ResponseStatus', 130 | filename=None, 131 | file=DESCRIPTOR, 132 | create_key=_descriptor._internal_create_key, 133 | values=[ 134 | _descriptor.EnumValueDescriptor( 135 | name='SUCCESS', index=0, number=0, 136 | serialized_options=None, 137 | type=None, 138 | create_key=_descriptor._internal_create_key), 139 | _descriptor.EnumValueDescriptor( 140 | name='FAILED', index=1, number=1, 141 | serialized_options=None, 142 | type=None, 143 | create_key=_descriptor._internal_create_key), 144 | ], 145 | containing_type=None, 146 | serialized_options=None, 147 | serialized_start=1181, 148 | serialized_end=1222, 149 | ) 150 | _sym_db.RegisterEnumDescriptor(_RESPONSESTATUS) 151 | 152 | ResponseStatus = enum_type_wrapper.EnumTypeWrapper(_RESPONSESTATUS) 153 | SendingKanban = 0 154 | SendingFile_CONT = 1 155 | SendingFile_EOF = 2 156 | SendingFile_FAILED = 3 157 | EOS = 4 158 | Unknown = 0 159 | Failed = 1 160 | OK = 2 161 | START_SERVICE = 0 162 | START_SERVICE_WITHOUT_KANBAN = 1 163 | SUCCESS = 0 164 | FAILED = 1 165 | 166 | 167 | 168 | _STATUSKANBAN = _descriptor.Descriptor( 169 | name='StatusKanban', 170 | full_name='kanbanpb.StatusKanban', 171 | filename=None, 172 | file=DESCRIPTOR, 173 | containing_type=None, 174 | create_key=_descriptor._internal_create_key, 175 | fields=[ 176 | _descriptor.FieldDescriptor( 177 | name='startAt', full_name='kanbanpb.StatusKanban.startAt', index=0, 178 | number=1, type=9, cpp_type=9, label=1, 179 | has_default_value=False, default_value=b"".decode('utf-8'), 180 | message_type=None, enum_type=None, containing_type=None, 181 | is_extension=False, extension_scope=None, 182 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 183 | _descriptor.FieldDescriptor( 184 | name='finishAt', full_name='kanbanpb.StatusKanban.finishAt', index=1, 185 | number=2, type=9, cpp_type=9, label=1, 186 | has_default_value=False, default_value=b"".decode('utf-8'), 187 | message_type=None, enum_type=None, containing_type=None, 188 | is_extension=False, extension_scope=None, 189 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 190 | _descriptor.FieldDescriptor( 191 | name='nextDeviceName', full_name='kanbanpb.StatusKanban.nextDeviceName', index=2, 192 | number=3, type=9, cpp_type=9, label=1, 193 | has_default_value=False, default_value=b"".decode('utf-8'), 194 | message_type=None, enum_type=None, containing_type=None, 195 | is_extension=False, extension_scope=None, 196 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 197 | _descriptor.FieldDescriptor( 198 | name='connectionKey', full_name='kanbanpb.StatusKanban.connectionKey', index=3, 199 | number=4, type=9, cpp_type=9, label=1, 200 | has_default_value=False, default_value=b"".decode('utf-8'), 201 | message_type=None, enum_type=None, containing_type=None, 202 | is_extension=False, extension_scope=None, 203 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 204 | _descriptor.FieldDescriptor( 205 | name='processNumber', full_name='kanbanpb.StatusKanban.processNumber', index=4, 206 | number=5, type=5, cpp_type=1, label=1, 207 | has_default_value=False, default_value=0, 208 | message_type=None, enum_type=None, containing_type=None, 209 | is_extension=False, extension_scope=None, 210 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 211 | _descriptor.FieldDescriptor( 212 | name='priorSuccess', full_name='kanbanpb.StatusKanban.priorSuccess', index=5, 213 | number=6, type=8, cpp_type=7, label=1, 214 | has_default_value=False, default_value=False, 215 | message_type=None, enum_type=None, containing_type=None, 216 | is_extension=False, extension_scope=None, 217 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 218 | _descriptor.FieldDescriptor( 219 | name='dataPath', full_name='kanbanpb.StatusKanban.dataPath', index=6, 220 | number=7, type=9, cpp_type=9, label=1, 221 | has_default_value=False, default_value=b"".decode('utf-8'), 222 | message_type=None, enum_type=None, containing_type=None, 223 | is_extension=False, extension_scope=None, 224 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 225 | _descriptor.FieldDescriptor( 226 | name='fileList', full_name='kanbanpb.StatusKanban.fileList', index=7, 227 | number=8, type=9, cpp_type=9, label=3, 228 | has_default_value=False, default_value=[], 229 | message_type=None, enum_type=None, containing_type=None, 230 | is_extension=False, extension_scope=None, 231 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 232 | _descriptor.FieldDescriptor( 233 | name='metadata', full_name='kanbanpb.StatusKanban.metadata', index=8, 234 | number=9, type=11, cpp_type=10, label=1, 235 | has_default_value=False, default_value=None, 236 | message_type=None, enum_type=None, containing_type=None, 237 | is_extension=False, extension_scope=None, 238 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 239 | ], 240 | extensions=[ 241 | ], 242 | nested_types=[], 243 | enum_types=[ 244 | ], 245 | serialized_options=None, 246 | is_extendable=False, 247 | syntax='proto3', 248 | extension_ranges=[], 249 | oneofs=[ 250 | ], 251 | serialized_start=99, 252 | serialized_end=319, 253 | ) 254 | 255 | 256 | _SENDKANBAN = _descriptor.Descriptor( 257 | name='SendKanban', 258 | full_name='kanbanpb.SendKanban', 259 | filename=None, 260 | file=DESCRIPTOR, 261 | containing_type=None, 262 | create_key=_descriptor._internal_create_key, 263 | fields=[ 264 | _descriptor.FieldDescriptor( 265 | name='deviceName', full_name='kanbanpb.SendKanban.deviceName', index=0, 266 | number=1, type=9, cpp_type=9, label=1, 267 | has_default_value=False, default_value=b"".decode('utf-8'), 268 | message_type=None, enum_type=None, containing_type=None, 269 | is_extension=False, extension_scope=None, 270 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 271 | _descriptor.FieldDescriptor( 272 | name='deviceAddr', full_name='kanbanpb.SendKanban.deviceAddr', index=1, 273 | number=2, type=9, cpp_type=9, label=1, 274 | has_default_value=False, default_value=b"".decode('utf-8'), 275 | message_type=None, enum_type=None, containing_type=None, 276 | is_extension=False, extension_scope=None, 277 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 278 | _descriptor.FieldDescriptor( 279 | name='nextService', full_name='kanbanpb.SendKanban.nextService', index=2, 280 | number=3, type=9, cpp_type=9, label=1, 281 | has_default_value=False, default_value=b"".decode('utf-8'), 282 | message_type=None, enum_type=None, containing_type=None, 283 | is_extension=False, extension_scope=None, 284 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 285 | _descriptor.FieldDescriptor( 286 | name='nextNumber', full_name='kanbanpb.SendKanban.nextNumber', index=3, 287 | number=4, type=5, cpp_type=1, label=1, 288 | has_default_value=False, default_value=0, 289 | message_type=None, enum_type=None, containing_type=None, 290 | is_extension=False, extension_scope=None, 291 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 292 | _descriptor.FieldDescriptor( 293 | name='afterKanban', full_name='kanbanpb.SendKanban.afterKanban', index=4, 294 | number=5, type=11, cpp_type=10, label=1, 295 | has_default_value=False, default_value=None, 296 | message_type=None, enum_type=None, containing_type=None, 297 | is_extension=False, extension_scope=None, 298 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 299 | ], 300 | extensions=[ 301 | ], 302 | nested_types=[], 303 | enum_types=[ 304 | ], 305 | serialized_options=None, 306 | is_extendable=False, 307 | syntax='proto3', 308 | extension_ranges=[], 309 | oneofs=[ 310 | ], 311 | serialized_start=322, 312 | serialized_end=460, 313 | ) 314 | 315 | 316 | _CHUNK = _descriptor.Descriptor( 317 | name='Chunk', 318 | full_name='kanbanpb.Chunk', 319 | filename=None, 320 | file=DESCRIPTOR, 321 | containing_type=None, 322 | create_key=_descriptor._internal_create_key, 323 | fields=[ 324 | _descriptor.FieldDescriptor( 325 | name='context', full_name='kanbanpb.Chunk.context', index=0, 326 | number=1, type=12, cpp_type=9, label=1, 327 | has_default_value=False, default_value=b"", 328 | message_type=None, enum_type=None, containing_type=None, 329 | is_extension=False, extension_scope=None, 330 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 331 | _descriptor.FieldDescriptor( 332 | name='name', full_name='kanbanpb.Chunk.name', index=1, 333 | number=2, type=9, cpp_type=9, label=1, 334 | has_default_value=False, default_value=b"".decode('utf-8'), 335 | message_type=None, enum_type=None, containing_type=None, 336 | is_extension=False, extension_scope=None, 337 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 338 | ], 339 | extensions=[ 340 | ], 341 | nested_types=[], 342 | enum_types=[ 343 | ], 344 | serialized_options=None, 345 | is_extendable=False, 346 | syntax='proto3', 347 | extension_ranges=[], 348 | oneofs=[ 349 | ], 350 | serialized_start=462, 351 | serialized_end=500, 352 | ) 353 | 354 | 355 | _SENDCONTEXT = _descriptor.Descriptor( 356 | name='SendContext', 357 | full_name='kanbanpb.SendContext', 358 | filename=None, 359 | file=DESCRIPTOR, 360 | containing_type=None, 361 | create_key=_descriptor._internal_create_key, 362 | fields=[ 363 | _descriptor.FieldDescriptor( 364 | name='code', full_name='kanbanpb.SendContext.code', index=0, 365 | number=1, type=14, cpp_type=8, label=1, 366 | has_default_value=False, default_value=0, 367 | message_type=None, enum_type=None, containing_type=None, 368 | is_extension=False, extension_scope=None, 369 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 370 | _descriptor.FieldDescriptor( 371 | name='context', full_name='kanbanpb.SendContext.context', index=1, 372 | number=2, type=11, cpp_type=10, label=1, 373 | has_default_value=False, default_value=None, 374 | message_type=None, enum_type=None, containing_type=None, 375 | is_extension=False, extension_scope=None, 376 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 377 | ], 378 | extensions=[ 379 | ], 380 | nested_types=[], 381 | enum_types=[ 382 | ], 383 | serialized_options=None, 384 | is_extendable=False, 385 | syntax='proto3', 386 | extension_ranges=[], 387 | oneofs=[ 388 | ], 389 | serialized_start=502, 390 | serialized_end=597, 391 | ) 392 | 393 | 394 | _UPLOADSTATUS = _descriptor.Descriptor( 395 | name='UploadStatus', 396 | full_name='kanbanpb.UploadStatus', 397 | filename=None, 398 | file=DESCRIPTOR, 399 | containing_type=None, 400 | create_key=_descriptor._internal_create_key, 401 | fields=[ 402 | _descriptor.FieldDescriptor( 403 | name='Message', full_name='kanbanpb.UploadStatus.Message', index=0, 404 | number=1, type=9, cpp_type=9, label=1, 405 | has_default_value=False, default_value=b"".decode('utf-8'), 406 | message_type=None, enum_type=None, containing_type=None, 407 | is_extension=False, extension_scope=None, 408 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 409 | _descriptor.FieldDescriptor( 410 | name='statusCode', full_name='kanbanpb.UploadStatus.statusCode', index=1, 411 | number=2, type=14, cpp_type=8, label=1, 412 | has_default_value=False, default_value=0, 413 | message_type=None, enum_type=None, containing_type=None, 414 | is_extension=False, extension_scope=None, 415 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 416 | ], 417 | extensions=[ 418 | ], 419 | nested_types=[], 420 | enum_types=[ 421 | ], 422 | serialized_options=None, 423 | is_extendable=False, 424 | syntax='proto3', 425 | extension_ranges=[], 426 | oneofs=[ 427 | ], 428 | serialized_start=599, 429 | serialized_end=678, 430 | ) 431 | 432 | 433 | _INITIALIZESERVICE = _descriptor.Descriptor( 434 | name='InitializeService', 435 | full_name='kanbanpb.InitializeService', 436 | filename=None, 437 | file=DESCRIPTOR, 438 | containing_type=None, 439 | create_key=_descriptor._internal_create_key, 440 | fields=[ 441 | _descriptor.FieldDescriptor( 442 | name='initType', full_name='kanbanpb.InitializeService.initType', index=0, 443 | number=1, type=14, cpp_type=8, label=1, 444 | has_default_value=False, default_value=0, 445 | message_type=None, enum_type=None, containing_type=None, 446 | is_extension=False, extension_scope=None, 447 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 448 | _descriptor.FieldDescriptor( 449 | name='microserviceName', full_name='kanbanpb.InitializeService.microserviceName', index=1, 450 | number=2, type=9, cpp_type=9, label=1, 451 | has_default_value=False, default_value=b"".decode('utf-8'), 452 | message_type=None, enum_type=None, containing_type=None, 453 | is_extension=False, extension_scope=None, 454 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 455 | _descriptor.FieldDescriptor( 456 | name='processNumber', full_name='kanbanpb.InitializeService.processNumber', index=2, 457 | number=3, type=5, cpp_type=1, label=1, 458 | has_default_value=False, default_value=0, 459 | message_type=None, enum_type=None, containing_type=None, 460 | is_extension=False, extension_scope=None, 461 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 462 | ], 463 | extensions=[ 464 | ], 465 | nested_types=[], 466 | enum_types=[ 467 | ], 468 | serialized_options=None, 469 | is_extendable=False, 470 | syntax='proto3', 471 | extension_ranges=[], 472 | oneofs=[ 473 | ], 474 | serialized_start=680, 475 | serialized_end=792, 476 | ) 477 | 478 | 479 | _REQUEST = _descriptor.Descriptor( 480 | name='Request', 481 | full_name='kanbanpb.Request', 482 | filename=None, 483 | file=DESCRIPTOR, 484 | containing_type=None, 485 | create_key=_descriptor._internal_create_key, 486 | fields=[ 487 | _descriptor.FieldDescriptor( 488 | name='microserviceName', full_name='kanbanpb.Request.microserviceName', index=0, 489 | number=1, type=9, cpp_type=9, label=1, 490 | has_default_value=False, default_value=b"".decode('utf-8'), 491 | message_type=None, enum_type=None, containing_type=None, 492 | is_extension=False, extension_scope=None, 493 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 494 | _descriptor.FieldDescriptor( 495 | name='message', full_name='kanbanpb.Request.message', index=1, 496 | number=2, type=11, cpp_type=10, label=1, 497 | has_default_value=False, default_value=None, 498 | message_type=None, enum_type=None, containing_type=None, 499 | is_extension=False, extension_scope=None, 500 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 501 | ], 502 | extensions=[ 503 | ], 504 | nested_types=[], 505 | enum_types=[ 506 | ], 507 | serialized_options=None, 508 | is_extendable=False, 509 | syntax='proto3', 510 | extension_ranges=[], 511 | oneofs=[ 512 | ], 513 | serialized_start=794, 514 | serialized_end=870, 515 | ) 516 | 517 | 518 | _RESPONSE = _descriptor.Descriptor( 519 | name='Response', 520 | full_name='kanbanpb.Response', 521 | filename=None, 522 | file=DESCRIPTOR, 523 | containing_type=None, 524 | create_key=_descriptor._internal_create_key, 525 | fields=[ 526 | _descriptor.FieldDescriptor( 527 | name='status', full_name='kanbanpb.Response.status', index=0, 528 | number=1, type=14, cpp_type=8, label=1, 529 | has_default_value=False, default_value=0, 530 | message_type=None, enum_type=None, containing_type=None, 531 | is_extension=False, extension_scope=None, 532 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 533 | _descriptor.FieldDescriptor( 534 | name='error', full_name='kanbanpb.Response.error', index=1, 535 | number=2, type=9, cpp_type=9, label=1, 536 | has_default_value=False, default_value=b"".decode('utf-8'), 537 | message_type=None, enum_type=None, containing_type=None, 538 | is_extension=False, extension_scope=None, 539 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 540 | ], 541 | extensions=[ 542 | ], 543 | nested_types=[], 544 | enum_types=[ 545 | ], 546 | serialized_options=None, 547 | is_extendable=False, 548 | syntax='proto3', 549 | extension_ranges=[], 550 | oneofs=[ 551 | ], 552 | serialized_start=872, 553 | serialized_end=939, 554 | ) 555 | 556 | _STATUSKANBAN.fields_by_name['metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT 557 | _SENDKANBAN.fields_by_name['afterKanban'].message_type = _STATUSKANBAN 558 | _SENDCONTEXT.fields_by_name['code'].enum_type = _UPLOADREQUESTCODE 559 | _SENDCONTEXT.fields_by_name['context'].message_type = google_dot_protobuf_dot_any__pb2._ANY 560 | _UPLOADSTATUS.fields_by_name['statusCode'].enum_type = _UPLOADSTATUSCODE 561 | _INITIALIZESERVICE.fields_by_name['initType'].enum_type = _INITIALIZETYPE 562 | _REQUEST.fields_by_name['message'].message_type = _STATUSKANBAN 563 | _RESPONSE.fields_by_name['status'].enum_type = _RESPONSESTATUS 564 | DESCRIPTOR.message_types_by_name['StatusKanban'] = _STATUSKANBAN 565 | DESCRIPTOR.message_types_by_name['SendKanban'] = _SENDKANBAN 566 | DESCRIPTOR.message_types_by_name['Chunk'] = _CHUNK 567 | DESCRIPTOR.message_types_by_name['SendContext'] = _SENDCONTEXT 568 | DESCRIPTOR.message_types_by_name['UploadStatus'] = _UPLOADSTATUS 569 | DESCRIPTOR.message_types_by_name['InitializeService'] = _INITIALIZESERVICE 570 | DESCRIPTOR.message_types_by_name['Request'] = _REQUEST 571 | DESCRIPTOR.message_types_by_name['Response'] = _RESPONSE 572 | DESCRIPTOR.enum_types_by_name['UploadRequestCode'] = _UPLOADREQUESTCODE 573 | DESCRIPTOR.enum_types_by_name['UploadStatusCode'] = _UPLOADSTATUSCODE 574 | DESCRIPTOR.enum_types_by_name['InitializeType'] = _INITIALIZETYPE 575 | DESCRIPTOR.enum_types_by_name['ResponseStatus'] = _RESPONSESTATUS 576 | _sym_db.RegisterFileDescriptor(DESCRIPTOR) 577 | 578 | StatusKanban = _reflection.GeneratedProtocolMessageType('StatusKanban', (_message.Message,), { 579 | 'DESCRIPTOR' : _STATUSKANBAN, 580 | '__module__' : 'proto.kanbanpb.status_pb2' 581 | # @@protoc_insertion_point(class_scope:kanbanpb.StatusKanban) 582 | }) 583 | _sym_db.RegisterMessage(StatusKanban) 584 | 585 | SendKanban = _reflection.GeneratedProtocolMessageType('SendKanban', (_message.Message,), { 586 | 'DESCRIPTOR' : _SENDKANBAN, 587 | '__module__' : 'proto.kanbanpb.status_pb2' 588 | # @@protoc_insertion_point(class_scope:kanbanpb.SendKanban) 589 | }) 590 | _sym_db.RegisterMessage(SendKanban) 591 | 592 | Chunk = _reflection.GeneratedProtocolMessageType('Chunk', (_message.Message,), { 593 | 'DESCRIPTOR' : _CHUNK, 594 | '__module__' : 'proto.kanbanpb.status_pb2' 595 | # @@protoc_insertion_point(class_scope:kanbanpb.Chunk) 596 | }) 597 | _sym_db.RegisterMessage(Chunk) 598 | 599 | SendContext = _reflection.GeneratedProtocolMessageType('SendContext', (_message.Message,), { 600 | 'DESCRIPTOR' : _SENDCONTEXT, 601 | '__module__' : 'proto.kanbanpb.status_pb2' 602 | # @@protoc_insertion_point(class_scope:kanbanpb.SendContext) 603 | }) 604 | _sym_db.RegisterMessage(SendContext) 605 | 606 | UploadStatus = _reflection.GeneratedProtocolMessageType('UploadStatus', (_message.Message,), { 607 | 'DESCRIPTOR' : _UPLOADSTATUS, 608 | '__module__' : 'proto.kanbanpb.status_pb2' 609 | # @@protoc_insertion_point(class_scope:kanbanpb.UploadStatus) 610 | }) 611 | _sym_db.RegisterMessage(UploadStatus) 612 | 613 | InitializeService = _reflection.GeneratedProtocolMessageType('InitializeService', (_message.Message,), { 614 | 'DESCRIPTOR' : _INITIALIZESERVICE, 615 | '__module__' : 'proto.kanbanpb.status_pb2' 616 | # @@protoc_insertion_point(class_scope:kanbanpb.InitializeService) 617 | }) 618 | _sym_db.RegisterMessage(InitializeService) 619 | 620 | Request = _reflection.GeneratedProtocolMessageType('Request', (_message.Message,), { 621 | 'DESCRIPTOR' : _REQUEST, 622 | '__module__' : 'proto.kanbanpb.status_pb2' 623 | # @@protoc_insertion_point(class_scope:kanbanpb.Request) 624 | }) 625 | _sym_db.RegisterMessage(Request) 626 | 627 | Response = _reflection.GeneratedProtocolMessageType('Response', (_message.Message,), { 628 | 'DESCRIPTOR' : _RESPONSE, 629 | '__module__' : 'proto.kanbanpb.status_pb2' 630 | # @@protoc_insertion_point(class_scope:kanbanpb.Response) 631 | }) 632 | _sym_db.RegisterMessage(Response) 633 | 634 | 635 | DESCRIPTOR._options = None 636 | 637 | _KANBAN = _descriptor.ServiceDescriptor( 638 | name='Kanban', 639 | full_name='kanbanpb.Kanban', 640 | file=DESCRIPTOR, 641 | index=0, 642 | serialized_options=None, 643 | create_key=_descriptor._internal_create_key, 644 | serialized_start=1225, 645 | serialized_end=1358, 646 | methods=[ 647 | _descriptor.MethodDescriptor( 648 | name='ReceiveKanban', 649 | full_name='kanbanpb.Kanban.ReceiveKanban', 650 | index=0, 651 | containing_service=None, 652 | input_type=_INITIALIZESERVICE, 653 | output_type=_STATUSKANBAN, 654 | serialized_options=None, 655 | create_key=_descriptor._internal_create_key, 656 | ), 657 | _descriptor.MethodDescriptor( 658 | name='SendKanban', 659 | full_name='kanbanpb.Kanban.SendKanban', 660 | index=1, 661 | containing_service=None, 662 | input_type=_REQUEST, 663 | output_type=_RESPONSE, 664 | serialized_options=None, 665 | create_key=_descriptor._internal_create_key, 666 | ), 667 | ]) 668 | _sym_db.RegisterServiceDescriptor(_KANBAN) 669 | 670 | DESCRIPTOR.services_by_name['Kanban'] = _KANBAN 671 | 672 | 673 | _SENDANYTHING = _descriptor.ServiceDescriptor( 674 | name='SendAnything', 675 | full_name='kanbanpb.SendAnything', 676 | file=DESCRIPTOR, 677 | index=1, 678 | serialized_options=None, 679 | create_key=_descriptor._internal_create_key, 680 | serialized_start=1361, 681 | serialized_end=1515, 682 | methods=[ 683 | _descriptor.MethodDescriptor( 684 | name='ServiceBrokerConn', 685 | full_name='kanbanpb.SendAnything.ServiceBrokerConn', 686 | index=0, 687 | containing_service=None, 688 | input_type=_SENDKANBAN, 689 | output_type=_SENDKANBAN, 690 | serialized_options=None, 691 | create_key=_descriptor._internal_create_key, 692 | ), 693 | _descriptor.MethodDescriptor( 694 | name='SendToOtherDevices', 695 | full_name='kanbanpb.SendAnything.SendToOtherDevices', 696 | index=1, 697 | containing_service=None, 698 | input_type=_SENDCONTEXT, 699 | output_type=_UPLOADSTATUS, 700 | serialized_options=None, 701 | create_key=_descriptor._internal_create_key, 702 | ), 703 | ]) 704 | _sym_db.RegisterServiceDescriptor(_SENDANYTHING) 705 | 706 | DESCRIPTOR.services_by_name['SendAnything'] = _SENDANYTHING 707 | 708 | # @@protoc_insertion_point(module_scope) 709 | -------------------------------------------------------------------------------- /aion/proto/status_pb2_grpc.py: -------------------------------------------------------------------------------- 1 | # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! 2 | """Client and server classes corresponding to protobuf-defined services.""" 3 | import grpc 4 | 5 | from aion.proto import status_pb2 as proto_dot_kanbanpb_dot_status__pb2 6 | 7 | 8 | class KanbanStub(object): 9 | """Missing associated documentation comment in .proto file.""" 10 | 11 | def __init__(self, channel): 12 | """Constructor. 13 | 14 | Args: 15 | channel: A grpc.Channel. 16 | """ 17 | self.ReceiveKanban = channel.unary_stream( 18 | '/kanbanpb.Kanban/ReceiveKanban', 19 | request_serializer=proto_dot_kanbanpb_dot_status__pb2.InitializeService.SerializeToString, 20 | response_deserializer=proto_dot_kanbanpb_dot_status__pb2.StatusKanban.FromString, 21 | ) 22 | self.SendKanban = channel.unary_unary( 23 | '/kanbanpb.Kanban/SendKanban', 24 | request_serializer=proto_dot_kanbanpb_dot_status__pb2.Request.SerializeToString, 25 | response_deserializer=proto_dot_kanbanpb_dot_status__pb2.Response.FromString, 26 | ) 27 | 28 | 29 | class KanbanServicer(object): 30 | """Missing associated documentation comment in .proto file.""" 31 | 32 | def ReceiveKanban(self, request, context): 33 | """最新のCカンバンを取得する 34 | """ 35 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 36 | context.set_details('Method not implemented!') 37 | raise NotImplementedError('Method not implemented!') 38 | 39 | def SendKanban(self, request, context): 40 | """Missing associated documentation comment in .proto file.""" 41 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 42 | context.set_details('Method not implemented!') 43 | raise NotImplementedError('Method not implemented!') 44 | 45 | 46 | def add_KanbanServicer_to_server(servicer, server): 47 | rpc_method_handlers = { 48 | 'ReceiveKanban': grpc.unary_stream_rpc_method_handler( 49 | servicer.ReceiveKanban, 50 | request_deserializer=proto_dot_kanbanpb_dot_status__pb2.InitializeService.FromString, 51 | response_serializer=proto_dot_kanbanpb_dot_status__pb2.StatusKanban.SerializeToString, 52 | ), 53 | 'SendKanban': grpc.unary_unary_rpc_method_handler( 54 | servicer.SendKanban, 55 | request_deserializer=proto_dot_kanbanpb_dot_status__pb2.Request.FromString, 56 | response_serializer=proto_dot_kanbanpb_dot_status__pb2.Response.SerializeToString, 57 | ), 58 | } 59 | generic_handler = grpc.method_handlers_generic_handler( 60 | 'kanbanpb.Kanban', rpc_method_handlers) 61 | server.add_generic_rpc_handlers((generic_handler,)) 62 | 63 | 64 | # This class is part of an EXPERIMENTAL API. 65 | class Kanban(object): 66 | """Missing associated documentation comment in .proto file.""" 67 | 68 | @staticmethod 69 | def ReceiveKanban(request, 70 | target, 71 | options=(), 72 | channel_credentials=None, 73 | call_credentials=None, 74 | insecure=False, 75 | compression=None, 76 | wait_for_ready=None, 77 | timeout=None, 78 | metadata=None): 79 | return grpc.experimental.unary_stream(request, target, '/kanbanpb.Kanban/ReceiveKanban', 80 | proto_dot_kanbanpb_dot_status__pb2.InitializeService.SerializeToString, 81 | proto_dot_kanbanpb_dot_status__pb2.StatusKanban.FromString, 82 | options, channel_credentials, 83 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 84 | 85 | @staticmethod 86 | def SendKanban(request, 87 | target, 88 | options=(), 89 | channel_credentials=None, 90 | call_credentials=None, 91 | insecure=False, 92 | compression=None, 93 | wait_for_ready=None, 94 | timeout=None, 95 | metadata=None): 96 | return grpc.experimental.unary_unary(request, target, '/kanbanpb.Kanban/SendKanban', 97 | proto_dot_kanbanpb_dot_status__pb2.Request.SerializeToString, 98 | proto_dot_kanbanpb_dot_status__pb2.Response.FromString, 99 | options, channel_credentials, 100 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 101 | 102 | 103 | class SendAnythingStub(object): 104 | """Missing associated documentation comment in .proto file.""" 105 | 106 | def __init__(self, channel): 107 | """Constructor. 108 | 109 | Args: 110 | channel: A grpc.Channel. 111 | """ 112 | self.ServiceBrokerConn = channel.stream_stream( 113 | '/kanbanpb.SendAnything/ServiceBrokerConn', 114 | request_serializer=proto_dot_kanbanpb_dot_status__pb2.SendKanban.SerializeToString, 115 | response_deserializer=proto_dot_kanbanpb_dot_status__pb2.SendKanban.FromString, 116 | ) 117 | self.SendToOtherDevices = channel.stream_unary( 118 | '/kanbanpb.SendAnything/SendToOtherDevices', 119 | request_serializer=proto_dot_kanbanpb_dot_status__pb2.SendContext.SerializeToString, 120 | response_deserializer=proto_dot_kanbanpb_dot_status__pb2.UploadStatus.FromString, 121 | ) 122 | 123 | 124 | class SendAnythingServicer(object): 125 | """Missing associated documentation comment in .proto file.""" 126 | 127 | def ServiceBrokerConn(self, request_iterator, context): 128 | """Missing associated documentation comment in .proto file.""" 129 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 130 | context.set_details('Method not implemented!') 131 | raise NotImplementedError('Method not implemented!') 132 | 133 | def SendToOtherDevices(self, request_iterator, context): 134 | """Missing associated documentation comment in .proto file.""" 135 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 136 | context.set_details('Method not implemented!') 137 | raise NotImplementedError('Method not implemented!') 138 | 139 | 140 | def add_SendAnythingServicer_to_server(servicer, server): 141 | rpc_method_handlers = { 142 | 'ServiceBrokerConn': grpc.stream_stream_rpc_method_handler( 143 | servicer.ServiceBrokerConn, 144 | request_deserializer=proto_dot_kanbanpb_dot_status__pb2.SendKanban.FromString, 145 | response_serializer=proto_dot_kanbanpb_dot_status__pb2.SendKanban.SerializeToString, 146 | ), 147 | 'SendToOtherDevices': grpc.stream_unary_rpc_method_handler( 148 | servicer.SendToOtherDevices, 149 | request_deserializer=proto_dot_kanbanpb_dot_status__pb2.SendContext.FromString, 150 | response_serializer=proto_dot_kanbanpb_dot_status__pb2.UploadStatus.SerializeToString, 151 | ), 152 | } 153 | generic_handler = grpc.method_handlers_generic_handler( 154 | 'kanbanpb.SendAnything', rpc_method_handlers) 155 | server.add_generic_rpc_handlers((generic_handler,)) 156 | 157 | 158 | # This class is part of an EXPERIMENTAL API. 159 | class SendAnything(object): 160 | """Missing associated documentation comment in .proto file.""" 161 | 162 | @staticmethod 163 | def ServiceBrokerConn(request_iterator, 164 | target, 165 | options=(), 166 | channel_credentials=None, 167 | call_credentials=None, 168 | insecure=False, 169 | compression=None, 170 | wait_for_ready=None, 171 | timeout=None, 172 | metadata=None): 173 | return grpc.experimental.stream_stream(request_iterator, target, '/kanbanpb.SendAnything/ServiceBrokerConn', 174 | proto_dot_kanbanpb_dot_status__pb2.SendKanban.SerializeToString, 175 | proto_dot_kanbanpb_dot_status__pb2.SendKanban.FromString, 176 | options, channel_credentials, 177 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 178 | 179 | @staticmethod 180 | def SendToOtherDevices(request_iterator, 181 | target, 182 | options=(), 183 | channel_credentials=None, 184 | call_credentials=None, 185 | insecure=False, 186 | compression=None, 187 | wait_for_ready=None, 188 | timeout=None, 189 | metadata=None): 190 | return grpc.experimental.stream_unary(request_iterator, target, '/kanbanpb.SendAnything/SendToOtherDevices', 191 | proto_dot_kanbanpb_dot_status__pb2.SendContext.SerializeToString, 192 | proto_dot_kanbanpb_dot_status__pb2.UploadStatus.FromString, 193 | options, channel_credentials, 194 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 195 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | protobuf>=3.11.3 2 | python-dateutil 3 | grpcio 4 | mysqlclient 5 | pymongo 6 | retry -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | def _read_requires_from_file(filename): 4 | return open(filename).read().splitlines() 5 | 6 | setup( 7 | name = "aion", 8 | version = "0.1.0", 9 | author="Yasumori KUBOTA", 10 | author_email="yasumori.k@latonaio", 11 | packages = find_packages(), 12 | install_requires = _read_requires_from_file("requirements.txt") 13 | ) 14 | -------------------------------------------------------------------------------- /test/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | ENV TZ="Asia/Tokyo" 3 | VOLUME ../:/var/test 4 | WORKDIR /var/test 5 | RUN apt-get update && apt-get install -y python3 python3-pip python3-dev libmysqlclient-dev && apt-get update 6 | CMD ["pip3","install","."] -------------------------------------------------------------------------------- /test/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | test: 4 | image: ubuntu 5 | tty: true 6 | volumes: 7 | - ./src/aion-related-python-library:/var/test 8 | dns: 8.8.8.8 9 | environment: 10 | TZ: 'Asia/Tokyo' 11 | working_dir: /var/test 12 | command: > 13 | bash -c 14 | "apt-get update && 15 | apt-get install -y python3 python3-pip python3-dev libmysqlclient-dev && 16 | apt-get update && 17 | pip3 install ." --------------------------------------------------------------------------------