Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added game_world.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions proto/chunk.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ service FileServer {
}

message Chunk {
bytes buffer = 1;
string hash = 1;
bytes buffer = 2;
}

message Request {
string name = 1;
}

message Reply {
int32 length = 1;
string msg = 1;
int32 length = 2;
}
2 changes: 1 addition & 1 deletion proto/codegen.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python -m grpc_tools.protoc -I. --python_out=../src --grpc_python_out=../src ./chunk.proto
python3 -m grpc_tools.protoc -I. --python_out=../src --pyi_out=../src --grpc_python_out=../src ./chunk.proto
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
grpcio==1.51.1
grpcio-tools==1.51.1
pkg_resources==0.0.0
protobuf==4.21.12
183 changes: 17 additions & 166 deletions src/chunk_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions src/chunk_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Optional as _Optional

DESCRIPTOR: _descriptor.FileDescriptor

class Chunk(_message.Message):
__slots__ = ["buffer", "hash"]
BUFFER_FIELD_NUMBER: _ClassVar[int]
HASH_FIELD_NUMBER: _ClassVar[int]
buffer: bytes
hash: str
def __init__(self, hash: _Optional[str] = ..., buffer: _Optional[bytes] = ...) -> None: ...

class Reply(_message.Message):
__slots__ = ["length", "msg"]
LENGTH_FIELD_NUMBER: _ClassVar[int]
MSG_FIELD_NUMBER: _ClassVar[int]
length: int
msg: str
def __init__(self, msg: _Optional[str] = ..., length: _Optional[int] = ...) -> None: ...

class Request(_message.Message):
__slots__ = ["name"]
NAME_FIELD_NUMBER: _ClassVar[int]
name: str
def __init__(self, name: _Optional[str] = ...) -> None: ...
132 changes: 84 additions & 48 deletions src/chunk_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,99 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

import chunk_pb2 as chunk__pb2


class FileServerStub(object):
# missing associated documentation comment in .proto file
pass

def __init__(self, channel):
"""Constructor.

Args:
channel: A grpc.Channel.
"""
self.upload = channel.stream_unary(
'/FileServer/upload',
request_serializer=chunk__pb2.Chunk.SerializeToString,
response_deserializer=chunk__pb2.Reply.FromString,
)
self.download = channel.unary_stream(
'/FileServer/download',
request_serializer=chunk__pb2.Request.SerializeToString,
response_deserializer=chunk__pb2.Chunk.FromString,
)
"""Missing associated documentation comment in .proto file."""

def __init__(self, channel):
"""Constructor.

Args:
channel: A grpc.Channel.
"""
self.upload = channel.stream_unary(
'/FileServer/upload',
request_serializer=chunk__pb2.Chunk.SerializeToString,
response_deserializer=chunk__pb2.Reply.FromString,
)
self.download = channel.unary_stream(
'/FileServer/download',
request_serializer=chunk__pb2.Request.SerializeToString,
response_deserializer=chunk__pb2.Chunk.FromString,
)


class FileServerServicer(object):
# missing associated documentation comment in .proto file
pass
"""Missing associated documentation comment in .proto file."""

def upload(self, request_iterator, context):
# missing associated documentation comment in .proto file
pass
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def upload(self, request_iterator, 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 download(self, request, context):
# missing associated documentation comment in .proto file
pass
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def download(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_FileServerServicer_to_server(servicer, server):
rpc_method_handlers = {
'upload': grpc.stream_unary_rpc_method_handler(
servicer.upload,
request_deserializer=chunk__pb2.Chunk.FromString,
response_serializer=chunk__pb2.Reply.SerializeToString,
),
'download': grpc.unary_stream_rpc_method_handler(
servicer.download,
request_deserializer=chunk__pb2.Request.FromString,
response_serializer=chunk__pb2.Chunk.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'FileServer', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
rpc_method_handlers = {
'upload': grpc.stream_unary_rpc_method_handler(
servicer.upload,
request_deserializer=chunk__pb2.Chunk.FromString,
response_serializer=chunk__pb2.Reply.SerializeToString,
),
'download': grpc.unary_stream_rpc_method_handler(
servicer.download,
request_deserializer=chunk__pb2.Request.FromString,
response_serializer=chunk__pb2.Chunk.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'FileServer', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))


# This class is part of an EXPERIMENTAL API.
class FileServer(object):
"""Missing associated documentation comment in .proto file."""

@staticmethod
def upload(request_iterator,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.stream_unary(request_iterator, target, '/FileServer/upload',
chunk__pb2.Chunk.SerializeToString,
chunk__pb2.Reply.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def download(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_stream(request, target, '/FileServer/download',
chunk__pb2.Request.SerializeToString,
chunk__pb2.Chunk.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
Loading