def create(hatena_id: str, url: list[str]) -> list[str]: with grpc.insecure_channel('manager:50051') as channel: stub = manager_pb2_grpc.ManagerStub(channel) response = stub.CreateArticle( manager_pb2.CreateArticleRequest(hatenaID=hatena_id, url=url)) return response.new_created_url
def find_word(hatena_id: str) -> dict[str, int]: with grpc.insecure_channel('manager:50051') as channel: stub = manager_pb2_grpc.ManagerStub(channel) response = stub.GetWord(manager_pb2.GetWordRequest(hatenaID=hatena_id)) return response.wordCount
def update_wordcloud(hatena_id: str, wordcloud): with grpc.insecure_channel('manager:50051') as channel: stub = manager_pb2_grpc.ManagerStub(channel) response = stub.UpdateWordcloud( manager_pb2.UpdateWordcloudRequest(hatenaID=hatena_id, wordcloud=wordcloud))
def create(article: manager_pb2.Article()) -> bool: with grpc.insecure_channel('manager:50051') as channel: stub = manager_pb2_grpc.ManagerStub(channel) response = stub.CreateWord(createRequest(article)) return response.created