Rewritten in go and python

This commit is contained in:
2024-11-06 01:25:27 +04:00
parent 9f22d9678d
commit d8449237bb
50 changed files with 3824 additions and 879 deletions

View File

@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: recommender.proto
# Protobuf Python Version: 5.27.2
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
5,
27,
2,
'',
'recommender.proto'
)
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11recommender.proto\x12\x0brecommender\"\xf8\x01\n\x06\x46ilter\x12\x13\n\tmin_votes\x18\x01 \x01(\rH\x00\x12\x13\n\tmax_votes\x18\x02 \x01(\rH\x01\x12\x12\n\x08min_year\x18\x03 \x01(\rH\x02\x12\x12\n\x08max_year\x18\x04 \x01(\rH\x03\x12\x14\n\nmin_rating\x18\x05 \x01(\x02H\x04\x12\x14\n\nmax_rating\x18\x06 \x01(\x02H\x05\x42\x11\n\x0fmin_votes_oneofB\x11\n\x0fmax_votes_oneofB\x10\n\x0emin_year_oneofB\x10\n\x0emax_year_oneofB\x12\n\x10min_rating_oneofB\x12\n\x10max_rating_oneof\"G\n\x06Weight\x12\x0c\n\x04year\x18\x01 \x01(\r\x12\x0e\n\x06rating\x18\x02 \x01(\r\x12\x0e\n\x06genres\x18\x03 \x01(\r\x12\x0f\n\x07nconsts\x18\x04 \x01(\r\"o\n\x07Request\x12\x0f\n\x07tconsts\x18\x01 \x03(\t\x12\t\n\x01n\x18\x02 \x01(\r\x12#\n\x06\x66ilter\x18\x03 \x01(\x0b\x32\x13.recommender.Filter\x12#\n\x06weight\x18\x04 \x01(\x0b\x32\x13.recommender.Weight\"9\n\x08Response\x12-\n\x06movies\x18\x01 \x03(\x0b\x32\x1d.recommender.RecommendedMovie\"3\n\x10RecommendedMovie\x12\x0e\n\x06tconst\x18\x01 \x01(\t\x12\x0f\n\x07weights\x18\x02 \x03(\t2R\n\x0bRecommender\x12\x43\n\x12GetRecommendations\x12\x14.recommender.Request\x1a\x15.recommender.Response\"\x00\x42,Z*github.com/aykhans/movier/server/pkg/protob\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'recommender_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
_globals['DESCRIPTOR']._loaded_options = None
_globals['DESCRIPTOR']._serialized_options = b'Z*github.com/aykhans/movier/server/pkg/proto'
_globals['_FILTER']._serialized_start=35
_globals['_FILTER']._serialized_end=283
_globals['_WEIGHT']._serialized_start=285
_globals['_WEIGHT']._serialized_end=356
_globals['_REQUEST']._serialized_start=358
_globals['_REQUEST']._serialized_end=469
_globals['_RESPONSE']._serialized_start=471
_globals['_RESPONSE']._serialized_end=528
_globals['_RECOMMENDEDMOVIE']._serialized_start=530
_globals['_RECOMMENDEDMOVIE']._serialized_end=581
_globals['_RECOMMENDER']._serialized_start=583
_globals['_RECOMMENDER']._serialized_end=665
# @@protoc_insertion_point(module_scope)

View File

@@ -0,0 +1,60 @@
from google.protobuf.internal import containers as _containers
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
DESCRIPTOR: _descriptor.FileDescriptor
class Filter(_message.Message):
__slots__ = ("min_votes", "max_votes", "min_year", "max_year", "min_rating", "max_rating")
MIN_VOTES_FIELD_NUMBER: _ClassVar[int]
MAX_VOTES_FIELD_NUMBER: _ClassVar[int]
MIN_YEAR_FIELD_NUMBER: _ClassVar[int]
MAX_YEAR_FIELD_NUMBER: _ClassVar[int]
MIN_RATING_FIELD_NUMBER: _ClassVar[int]
MAX_RATING_FIELD_NUMBER: _ClassVar[int]
min_votes: int
max_votes: int
min_year: int
max_year: int
min_rating: float
max_rating: float
def __init__(self, min_votes: _Optional[int] = ..., max_votes: _Optional[int] = ..., min_year: _Optional[int] = ..., max_year: _Optional[int] = ..., min_rating: _Optional[float] = ..., max_rating: _Optional[float] = ...) -> None: ...
class Weight(_message.Message):
__slots__ = ("year", "rating", "genres", "nconsts")
YEAR_FIELD_NUMBER: _ClassVar[int]
RATING_FIELD_NUMBER: _ClassVar[int]
GENRES_FIELD_NUMBER: _ClassVar[int]
NCONSTS_FIELD_NUMBER: _ClassVar[int]
year: int
rating: int
genres: int
nconsts: int
def __init__(self, year: _Optional[int] = ..., rating: _Optional[int] = ..., genres: _Optional[int] = ..., nconsts: _Optional[int] = ...) -> None: ...
class Request(_message.Message):
__slots__ = ("tconsts", "n", "filter", "weight")
TCONSTS_FIELD_NUMBER: _ClassVar[int]
N_FIELD_NUMBER: _ClassVar[int]
FILTER_FIELD_NUMBER: _ClassVar[int]
WEIGHT_FIELD_NUMBER: _ClassVar[int]
tconsts: _containers.RepeatedScalarFieldContainer[str]
n: int
filter: Filter
weight: Weight
def __init__(self, tconsts: _Optional[_Iterable[str]] = ..., n: _Optional[int] = ..., filter: _Optional[_Union[Filter, _Mapping]] = ..., weight: _Optional[_Union[Weight, _Mapping]] = ...) -> None: ...
class Response(_message.Message):
__slots__ = ("movies",)
MOVIES_FIELD_NUMBER: _ClassVar[int]
movies: _containers.RepeatedCompositeFieldContainer[RecommendedMovie]
def __init__(self, movies: _Optional[_Iterable[_Union[RecommendedMovie, _Mapping]]] = ...) -> None: ...
class RecommendedMovie(_message.Message):
__slots__ = ("tconst", "weights")
TCONST_FIELD_NUMBER: _ClassVar[int]
WEIGHTS_FIELD_NUMBER: _ClassVar[int]
tconst: str
weights: _containers.RepeatedScalarFieldContainer[str]
def __init__(self, tconst: _Optional[str] = ..., weights: _Optional[_Iterable[str]] = ...) -> None: ...

View File

@@ -0,0 +1,97 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings
import recommender_pb2 as recommender__pb2
GRPC_GENERATED_VERSION = '1.67.0'
GRPC_VERSION = grpc.__version__
_version_not_supported = False
try:
from grpc._utilities import first_version_is_lower
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
_version_not_supported = True
if _version_not_supported:
raise RuntimeError(
f'The grpc package installed is at version {GRPC_VERSION},'
+ f' but the generated code in recommender_pb2_grpc.py depends on'
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
)
class RecommenderStub(object):
"""Missing associated documentation comment in .proto file."""
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.GetRecommendations = channel.unary_unary(
'/recommender.Recommender/GetRecommendations',
request_serializer=recommender__pb2.Request.SerializeToString,
response_deserializer=recommender__pb2.Response.FromString,
_registered_method=True)
class RecommenderServicer(object):
"""Missing associated documentation comment in .proto file."""
def GetRecommendations(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def add_RecommenderServicer_to_server(servicer, server):
rpc_method_handlers = {
'GetRecommendations': grpc.unary_unary_rpc_method_handler(
servicer.GetRecommendations,
request_deserializer=recommender__pb2.Request.FromString,
response_serializer=recommender__pb2.Response.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'recommender.Recommender', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
server.add_registered_method_handlers('recommender.Recommender', rpc_method_handlers)
# This class is part of an EXPERIMENTAL API.
class Recommender(object):
"""Missing associated documentation comment in .proto file."""
@staticmethod
def GetRecommendations(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(
request,
target,
'/recommender.Recommender/GetRecommendations',
recommender__pb2.Request.SerializeToString,
recommender__pb2.Response.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True)