Compare commits
13 Commits
1fa1b10699
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 67b9db2ed0 | |||
| ee741cc924 | |||
| 83a54a8848 | |||
| 6103ad47a5 | |||
| 8d1e31ac5f | |||
| 544b7d6c85 | |||
| e247bdc929 | |||
| 1542bd98c2 | |||
| 1d26d6625e | |||
| 3776bdca24 | |||
| 1876158d9d | |||
| a0d2d1cb7f | |||
| a99b5d0014 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
__pycache__
|
||||
/dist
|
||||
/src/funnel/env
|
||||
/src/serve_currenttime/target
|
||||
/src/serve_currenttime_rust/target
|
||||
/src/serve_currenttime/node_modules
|
||||
|
||||
83
README.md
83
README.md
@ -5,49 +5,48 @@
|
||||
|
||||
```plantuml
|
||||
@startuml
|
||||
participant FE as "Frontend" << React >>
|
||||
participant FE as "Frontend" << JavaScript >>
|
||||
participant WS as "WS Server" << Python >>
|
||||
participant Funnel as "Funnel" << Python >>
|
||||
participant Hours as "ServeHours" << Go >>
|
||||
participant Minutes as "ServeMinutes" << Go >>
|
||||
participant Seconds as "ServeSeconds" << Go >>
|
||||
participant Milliseconds as "ServeMilliseconds" << Go >>
|
||||
participant CurrentTime as "ServeCurrentTime" << Rust >>
|
||||
participant Segments as "ServeSegments" << Go >>
|
||||
participant CurrentTime as "ServeCurrentTime" << NodeJS >>
|
||||
|
||||
activate FE #hotpink
|
||||
FE -> FE: Load page
|
||||
FE -> Funnel: WS Connect
|
||||
FE -> WS: WS Connect
|
||||
|
||||
loop #ivory
|
||||
activate Funnel #gold
|
||||
Funnel -> Hours: GetHours()
|
||||
activate Hours #skyblue
|
||||
Hours -> CurrentTime: GetCurrentTime()
|
||||
Funnel -> Segments: GetHours()
|
||||
activate Segments #skyblue
|
||||
Segments -> CurrentTime: GetCurrentTime()
|
||||
activate CurrentTime #sandybrown
|
||||
return HH:MM:SS.ms
|
||||
return HH
|
||||
|
||||
Funnel -> Minutes: GetMinutes()
|
||||
activate Minutes #skyblue
|
||||
Minutes -> CurrentTime: GetCurrentTime()
|
||||
Funnel -> Segments: GetMinutes()
|
||||
activate Segments #skyblue
|
||||
Segments -> CurrentTime: GetCurrentTime()
|
||||
activate CurrentTime #sandybrown
|
||||
return HH:MM:SS.ms
|
||||
return MM
|
||||
|
||||
Funnel -> Seconds: GetSeconds()
|
||||
activate Seconds #skyblue
|
||||
Seconds -> CurrentTime: GetCurrentTime()
|
||||
Funnel -> Segments: GetSeconds()
|
||||
activate Segments #skyblue
|
||||
Segments -> CurrentTime: GetCurrentTime()
|
||||
activate CurrentTime #sandybrown
|
||||
return HH:MM:SS.ms
|
||||
return SS
|
||||
|
||||
Funnel -> Milliseconds: GetMilliseconds()
|
||||
activate Milliseconds #skyblue
|
||||
Milliseconds -> CurrentTime: GetCurrentTime()
|
||||
Funnel -> Segments: GetMilliseconds()
|
||||
activate Segments #skyblue
|
||||
Segments -> CurrentTime: GetCurrentTime()
|
||||
activate CurrentTime #sandybrown
|
||||
return HH:MM:SS.ms
|
||||
return ms
|
||||
|
||||
Funnel -> FE: WS: Send formatted time
|
||||
Funnel -> WS: WS: Send complete time
|
||||
WS --> FE: WS: Send complete time
|
||||
deactivate Funnel
|
||||
end
|
||||
deactivate FE
|
||||
@ -60,11 +59,9 @@ deactivate FE
|
||||
| Service | Language | Port |
|
||||
| -- | -- | -- |
|
||||
| Funnel | Python | - |
|
||||
| ServeCurrentTime | Rust | 50000 |
|
||||
| ServeHours | Go | 50001 |
|
||||
| ServeMinutes | Go | 50002 |
|
||||
| ServeSeconds | Go | 50003 |
|
||||
| ServeMilliseconds | Go | 50004 |
|
||||
| ServeCurrentTime | NodeJS | 50000 |
|
||||
| ServeSegments | Go | 50001 |
|
||||
| WS Server | Go | 50010 |
|
||||
|
||||
### Funnel
|
||||
|
||||
@ -103,11 +100,47 @@ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
|
||||
```
|
||||
|
||||
Install libraries:
|
||||
```sh
|
||||
go install
|
||||
```
|
||||
|
||||
Run service:
|
||||
```sh
|
||||
make run
|
||||
```
|
||||
|
||||
### Rust services
|
||||
|
||||
Update `rustc`
|
||||
|
||||
```sh
|
||||
rustup update
|
||||
```
|
||||
|
||||
#### [Tonic](https://github.com/hyperium/tonic)
|
||||
|
||||
Tonic is a gRPC over HTTP/2 implementation focused on high performance, interoperability, and flexibility. This library was created to have first class support of async/await and to act as a core building block for production systems written in Rust.
|
||||
|
||||
[Hello world tutorial](https://github.com/hyperium/tonic/blob/master/examples/helloworld-tutorial.md)
|
||||
|
||||
|
||||
[Rust and gRPC: A complete guide](https://blog.logrocket.com/rust-and-grpc-a-complete-guide/)
|
||||
|
||||
### NodeJS service
|
||||
|
||||
Requirements:
|
||||
- Node 16+
|
||||
- npm package manager
|
||||
|
||||
Install npm packages:
|
||||
```sh
|
||||
cd src/serve_currenttime
|
||||
npm install
|
||||
```
|
||||
|
||||
Run service:
|
||||
```sh
|
||||
cd src/serve_currenttime
|
||||
make run
|
||||
```
|
||||
|
||||
47
src/frontend/index.html
Normal file
47
src/frontend/index.html
Normal file
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Hello world</h1>
|
||||
|
||||
<h2 id="formatted-time">-</h2>
|
||||
<h3 id="comm-cycle">-</h3>
|
||||
</body>
|
||||
|
||||
<script type="module">
|
||||
const WS_HOST = "localhost";
|
||||
const WS_PORT = 50010;
|
||||
|
||||
window.onload = function () {
|
||||
const ws = new WebSocket(`ws://${WS_HOST}:${WS_PORT}`);
|
||||
|
||||
ws.onmessage = function (event) {
|
||||
const data = JSON.parse(event.data);
|
||||
//console.log("message received:", data)
|
||||
document.getElementById("formatted-time").innerHTML = data.formattedTime;
|
||||
document.getElementById("comm-cycle").innerHTML = data.commCycleStr;
|
||||
|
||||
//ws.close();
|
||||
}
|
||||
ws.onopen = function () {
|
||||
console.log("open");
|
||||
}
|
||||
ws.onclose = function () {
|
||||
console.log("close");
|
||||
}
|
||||
ws.onerror = function () {
|
||||
console.log("error");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</html>
|
||||
@ -1,11 +1,14 @@
|
||||
PROTO_DIR=../protos
|
||||
STUBS_DIR=./stubs
|
||||
PROTO_FILENAME=serve_hours.proto
|
||||
|
||||
run:
|
||||
@source env/bin/activate && \
|
||||
python main.py
|
||||
|
||||
run-ws:
|
||||
@source env/bin/activate && \
|
||||
python ws_server.py
|
||||
|
||||
proto:
|
||||
@source env/bin/activate && \
|
||||
python \
|
||||
@ -14,5 +17,7 @@ proto:
|
||||
--python_out=$(STUBS_DIR) \
|
||||
--pyi_out=$(STUBS_DIR) \
|
||||
--grpc_python_out=$(STUBS_DIR) \
|
||||
$(PROTO_DIR)/$(PROTO_FILENAME)
|
||||
$(PROTO_DIR)/serve_segments.proto \
|
||||
$(PROTO_DIR)/serve_currenttime.proto
|
||||
|
||||
@sed -i -E 's/^(import\s[a-zA-Z0-9_]+_pb2)/from . \1/g' $(STUBS_DIR)/*_grpc.py
|
||||
|
||||
@ -1,33 +1,113 @@
|
||||
import logging
|
||||
import grpc
|
||||
from stubs import serve_hours_pb2
|
||||
from stubs import serve_hours_pb2_grpc
|
||||
import asyncio
|
||||
import json
|
||||
import time
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import AsyncGenerator
|
||||
|
||||
SERVE_HOURS_HOST = "localhost"
|
||||
SERVE_HOURS_PORT = 50001
|
||||
SERVE_MINUTES_HOST = "localhost"
|
||||
SERVE_MINUTES_PORT = 50002
|
||||
SERVE_SECONDS_HOST = "localhost"
|
||||
SERVE_SECONDS_PORT = 50003
|
||||
SERVE_MILLISECONDS_HOST = "localhost"
|
||||
SERVE_MILLISECONDS_PORT = 50004
|
||||
import grpc
|
||||
import websockets
|
||||
from websockets.legacy.client import connect as ws_connect
|
||||
|
||||
from stubs.serve_segments_pb2 import (
|
||||
GetHoursRequest,
|
||||
GetHoursResponse,
|
||||
GetMillisecondsRequest,
|
||||
GetMillisecondsResponse,
|
||||
GetMinutesRequest,
|
||||
GetMinutesResponse,
|
||||
GetSecondsRequest,
|
||||
GetSecondsResponse,
|
||||
)
|
||||
from stubs.serve_segments_pb2_grpc import ServeSegmentsStub
|
||||
|
||||
SERVE_CURRENTTIME_HOST = "localhost"
|
||||
SERVE_CURRENTTIME_PORT = 50000
|
||||
SERVE_SEGMENTS_HOST = "localhost"
|
||||
SERVE_SEGMENTS_PORT = 50001
|
||||
WS_HOST = "localhost"
|
||||
WS_PORT = 50010
|
||||
|
||||
TIMEZONE = "Europe/Zagreb"
|
||||
|
||||
|
||||
def get_hours() -> int:
|
||||
with grpc.insecure_channel(f"{SERVE_HOURS_HOST}:{SERVE_HOURS_PORT}") as channel:
|
||||
stub = serve_hours_pb2_grpc.ServeHoursStub(channel)
|
||||
response = stub.GetHours(serve_hours_pb2.GetHoursRequest(timezone=TIMEZONE))
|
||||
print("GetHours() response: ", response)
|
||||
return response.hours
|
||||
@asynccontextmanager
|
||||
async def get_serve_segments_stub() -> AsyncGenerator[ServeSegmentsStub, None]:
|
||||
"""Connect to segments server and create stub"""
|
||||
serve_segments_addr = f"{SERVE_SEGMENTS_HOST}:{SERVE_SEGMENTS_PORT}"
|
||||
async with grpc.aio.insecure_channel(serve_segments_addr) as channel:
|
||||
print(f"🖥 Connected to ServeSegments server on {serve_segments_addr}")
|
||||
yield ServeSegmentsStub(channel)
|
||||
|
||||
|
||||
def run():
|
||||
hours = get_hours()
|
||||
print(">>>>>>>>>>>>> Hours:", hours)
|
||||
async def get_hours(stub: ServeSegmentsStub) -> int:
|
||||
response: GetHoursResponse = await stub.GetHours(GetHoursRequest(timezone=TIMEZONE))
|
||||
return response.hours
|
||||
|
||||
|
||||
async def get_minutes(stub: ServeSegmentsStub) -> int:
|
||||
response: GetMinutesResponse = await stub.GetMinutes(
|
||||
GetMinutesRequest(timezone=TIMEZONE)
|
||||
)
|
||||
return response.minutes
|
||||
|
||||
|
||||
async def get_seconds(stub: ServeSegmentsStub) -> int:
|
||||
response: GetSecondsResponse = await stub.GetSeconds(
|
||||
GetSecondsRequest(timezone=TIMEZONE)
|
||||
)
|
||||
return response.seconds
|
||||
|
||||
|
||||
async def get_milliseconds(stub: ServeSegmentsStub) -> int:
|
||||
response: GetMillisecondsResponse = await stub.GetMilliseconds(
|
||||
GetMillisecondsRequest(timezone=TIMEZONE)
|
||||
)
|
||||
return response.milliseconds
|
||||
|
||||
|
||||
async def main():
|
||||
ws_uri = f"ws://{WS_HOST}:{WS_PORT}"
|
||||
async with ws_connect(uri=ws_uri) as websocket:
|
||||
async with get_serve_segments_stub() as stub:
|
||||
while True:
|
||||
t = time.perf_counter()
|
||||
|
||||
# create tasks
|
||||
task_hours = asyncio.create_task(get_hours(stub))
|
||||
task_minutes = asyncio.create_task(get_minutes(stub))
|
||||
task_seconds = asyncio.create_task(get_seconds(stub))
|
||||
task_milliseconds = asyncio.create_task(get_milliseconds(stub))
|
||||
|
||||
# exec tasks asynchronously
|
||||
await asyncio.gather(
|
||||
task_hours, task_minutes, task_seconds, task_milliseconds
|
||||
)
|
||||
|
||||
# get results
|
||||
hours = task_hours.result()
|
||||
minutes = task_minutes.result()
|
||||
seconds = task_seconds.result()
|
||||
milliseconds = task_milliseconds.result()
|
||||
formatted_time = (
|
||||
f"{hours:02d}:{minutes:02d}:{seconds:02d}:{milliseconds:03d}"
|
||||
)
|
||||
comm_cycle = time.perf_counter() - t
|
||||
|
||||
data = {
|
||||
"hours": hours,
|
||||
"minutes": minutes,
|
||||
"seconds": seconds,
|
||||
"milliseconds": milliseconds,
|
||||
"formattedTime": formatted_time,
|
||||
"commCycle": comm_cycle,
|
||||
"commCycleStr": f"{comm_cycle:0.4f}",
|
||||
}
|
||||
|
||||
await websocket.send(json.dumps(data))
|
||||
await websocket.recv()
|
||||
|
||||
print(f"RESULT: {formatted_time}, T: {comm_cycle}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig()
|
||||
run()
|
||||
asyncio.run(main())
|
||||
|
||||
12
src/funnel/models.py
Normal file
12
src/funnel/models.py
Normal file
@ -0,0 +1,12 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class GetCurrentTimeResponse(BaseModel):
|
||||
hours: int
|
||||
minutes: int
|
||||
seconds: int
|
||||
milliseconds: int
|
||||
formatted_time: str
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
@ -1,2 +1,4 @@
|
||||
pydantic
|
||||
grpcio
|
||||
grpcio-tools
|
||||
websockets
|
||||
|
||||
30
src/funnel/stubs/serve_currenttime_pb2.py
Normal file
30
src/funnel/stubs/serve_currenttime_pb2.py
Normal file
@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: serve_currenttime.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf.internal import builder as _builder
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x17serve_currenttime.proto\x12\x11serve_currenttime\")\n\x15GetCurrentTimeRequest\x12\x10\n\x08timezone\x18\x01 \x01(\t\"w\n\x16GetCurrentTimeResponse\x12\r\n\x05hours\x18\x01 \x01(\r\x12\x0f\n\x07minutes\x18\x02 \x01(\r\x12\x0f\n\x07seconds\x18\x03 \x01(\r\x12\x14\n\x0cmilliseconds\x18\x04 \x01(\r\x12\x16\n\x0e\x66ormatted_time\x18\x05 \x01(\t2\x80\x01\n\x17ServeCurrentTimeService\x12\x65\n\x0eGetCurrentTime\x12(.serve_currenttime.GetCurrentTimeRequest\x1a).serve_currenttime.GetCurrentTimeResponseB.Z,example.com/project/protos/serve_currenttimeb\x06proto3')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'serve_currenttime_pb2', globals())
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
DESCRIPTOR._serialized_options = b'Z,example.com/project/protos/serve_currenttime'
|
||||
_GETCURRENTTIMEREQUEST._serialized_start=46
|
||||
_GETCURRENTTIMEREQUEST._serialized_end=87
|
||||
_GETCURRENTTIMERESPONSE._serialized_start=89
|
||||
_GETCURRENTTIMERESPONSE._serialized_end=208
|
||||
_SERVECURRENTTIMESERVICE._serialized_start=211
|
||||
_SERVECURRENTTIMESERVICE._serialized_end=339
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
25
src/funnel/stubs/serve_currenttime_pb2.pyi
Normal file
25
src/funnel/stubs/serve_currenttime_pb2.pyi
Normal file
@ -0,0 +1,25 @@
|
||||
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 GetCurrentTimeRequest(_message.Message):
|
||||
__slots__ = ["timezone"]
|
||||
TIMEZONE_FIELD_NUMBER: _ClassVar[int]
|
||||
timezone: str
|
||||
def __init__(self, timezone: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class GetCurrentTimeResponse(_message.Message):
|
||||
__slots__ = ["formatted_time", "hours", "milliseconds", "minutes", "seconds"]
|
||||
FORMATTED_TIME_FIELD_NUMBER: _ClassVar[int]
|
||||
HOURS_FIELD_NUMBER: _ClassVar[int]
|
||||
MILLISECONDS_FIELD_NUMBER: _ClassVar[int]
|
||||
MINUTES_FIELD_NUMBER: _ClassVar[int]
|
||||
SECONDS_FIELD_NUMBER: _ClassVar[int]
|
||||
formatted_time: str
|
||||
hours: int
|
||||
milliseconds: int
|
||||
minutes: int
|
||||
seconds: int
|
||||
def __init__(self, hours: _Optional[int] = ..., minutes: _Optional[int] = ..., seconds: _Optional[int] = ..., milliseconds: _Optional[int] = ..., formatted_time: _Optional[str] = ...) -> None: ...
|
||||
@ -2,10 +2,10 @@
|
||||
"""Client and server classes corresponding to protobuf-defined services."""
|
||||
import grpc
|
||||
|
||||
from . import serve_hours_pb2 as serve__hours__pb2
|
||||
from . import serve_currenttime_pb2 as serve__currenttime__pb2
|
||||
|
||||
|
||||
class ServeHoursStub(object):
|
||||
class ServeCurrentTimeServiceStub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def __init__(self, channel):
|
||||
@ -14,42 +14,42 @@ class ServeHoursStub(object):
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.GetHours = channel.unary_unary(
|
||||
'/ServeHours/GetHours',
|
||||
request_serializer=serve__hours__pb2.GetHoursRequest.SerializeToString,
|
||||
response_deserializer=serve__hours__pb2.GetHoursResponse.FromString,
|
||||
self.GetCurrentTime = channel.unary_unary(
|
||||
'/serve_currenttime.ServeCurrentTimeService/GetCurrentTime',
|
||||
request_serializer=serve__currenttime__pb2.GetCurrentTimeRequest.SerializeToString,
|
||||
response_deserializer=serve__currenttime__pb2.GetCurrentTimeResponse.FromString,
|
||||
)
|
||||
|
||||
|
||||
class ServeHoursServicer(object):
|
||||
class ServeCurrentTimeServiceServicer(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def GetHours(self, request, context):
|
||||
def GetCurrentTime(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_ServeHoursServicer_to_server(servicer, server):
|
||||
def add_ServeCurrentTimeServiceServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'GetHours': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetHours,
|
||||
request_deserializer=serve__hours__pb2.GetHoursRequest.FromString,
|
||||
response_serializer=serve__hours__pb2.GetHoursResponse.SerializeToString,
|
||||
'GetCurrentTime': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetCurrentTime,
|
||||
request_deserializer=serve__currenttime__pb2.GetCurrentTimeRequest.FromString,
|
||||
response_serializer=serve__currenttime__pb2.GetCurrentTimeResponse.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'ServeHours', rpc_method_handlers)
|
||||
'serve_currenttime.ServeCurrentTimeService', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
class ServeHours(object):
|
||||
class ServeCurrentTimeService(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
@staticmethod
|
||||
def GetHours(request,
|
||||
def GetCurrentTime(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
@ -59,8 +59,8 @@ class ServeHours(object):
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/ServeHours/GetHours',
|
||||
serve__hours__pb2.GetHoursRequest.SerializeToString,
|
||||
serve__hours__pb2.GetHoursResponse.FromString,
|
||||
return grpc.experimental.unary_unary(request, target, '/serve_currenttime.ServeCurrentTimeService/GetCurrentTime',
|
||||
serve__currenttime__pb2.GetCurrentTimeRequest.SerializeToString,
|
||||
serve__currenttime__pb2.GetCurrentTimeResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
@ -1,29 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: serve_hours.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf.internal import builder as _builder
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11serve_hours.proto\"#\n\x0fGetHoursRequest\x12\x10\n\x08timezone\x18\x01 \x01(\t\"!\n\x10GetHoursResponse\x12\r\n\x05hours\x18\x01 \x01(\r2=\n\nServeHours\x12/\n\x08GetHours\x12\x10.GetHoursRequest\x1a\x11.GetHoursResponseb\x06proto3')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'serve_hours_pb2', globals())
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
_GETHOURSREQUEST._serialized_start=21
|
||||
_GETHOURSREQUEST._serialized_end=56
|
||||
_GETHOURSRESPONSE._serialized_start=58
|
||||
_GETHOURSRESPONSE._serialized_end=91
|
||||
_SERVEHOURS._serialized_start=93
|
||||
_SERVEHOURS._serialized_end=154
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
@ -1,17 +0,0 @@
|
||||
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 GetHoursRequest(_message.Message):
|
||||
__slots__ = ["timezone"]
|
||||
TIMEZONE_FIELD_NUMBER: _ClassVar[int]
|
||||
timezone: str
|
||||
def __init__(self, timezone: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class GetHoursResponse(_message.Message):
|
||||
__slots__ = ["hours"]
|
||||
HOURS_FIELD_NUMBER: _ClassVar[int]
|
||||
hours: int
|
||||
def __init__(self, hours: _Optional[int] = ...) -> None: ...
|
||||
42
src/funnel/stubs/serve_segments_pb2.py
Normal file
42
src/funnel/stubs/serve_segments_pb2.py
Normal file
@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: serve_segments.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf.internal import builder as _builder
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14serve_segments.proto\"#\n\x0fGetHoursRequest\x12\x10\n\x08timezone\x18\x01 \x01(\t\"%\n\x11GetMinutesRequest\x12\x10\n\x08timezone\x18\x01 \x01(\t\"%\n\x11GetSecondsRequest\x12\x10\n\x08timezone\x18\x01 \x01(\t\"*\n\x16GetMillisecondsRequest\x12\x10\n\x08timezone\x18\x01 \x01(\t\"!\n\x10GetHoursResponse\x12\r\n\x05hours\x18\x01 \x01(\r\"%\n\x12GetMinutesResponse\x12\x0f\n\x07minutes\x18\x01 \x01(\r\"%\n\x12GetSecondsResponse\x12\x0f\n\x07seconds\x18\x01 \x01(\r\"/\n\x17GetMillisecondsResponse\x12\x14\n\x0cmilliseconds\x18\x01 \x01(\r2\xf4\x01\n\rServeSegments\x12/\n\x08GetHours\x12\x10.GetHoursRequest\x1a\x11.GetHoursResponse\x12\x35\n\nGetMinutes\x12\x12.GetMinutesRequest\x1a\x13.GetMinutesResponse\x12\x35\n\nGetSeconds\x12\x12.GetSecondsRequest\x1a\x13.GetSecondsResponse\x12\x44\n\x0fGetMilliseconds\x12\x17.GetMillisecondsRequest\x1a\x18.GetMillisecondsResponseB+Z)example.com/project/protos/serve_segmentsb\x06proto3')
|
||||
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'serve_segments_pb2', globals())
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
DESCRIPTOR._serialized_options = b'Z)example.com/project/protos/serve_segments'
|
||||
_GETHOURSREQUEST._serialized_start=24
|
||||
_GETHOURSREQUEST._serialized_end=59
|
||||
_GETMINUTESREQUEST._serialized_start=61
|
||||
_GETMINUTESREQUEST._serialized_end=98
|
||||
_GETSECONDSREQUEST._serialized_start=100
|
||||
_GETSECONDSREQUEST._serialized_end=137
|
||||
_GETMILLISECONDSREQUEST._serialized_start=139
|
||||
_GETMILLISECONDSREQUEST._serialized_end=181
|
||||
_GETHOURSRESPONSE._serialized_start=183
|
||||
_GETHOURSRESPONSE._serialized_end=216
|
||||
_GETMINUTESRESPONSE._serialized_start=218
|
||||
_GETMINUTESRESPONSE._serialized_end=255
|
||||
_GETSECONDSRESPONSE._serialized_start=257
|
||||
_GETSECONDSRESPONSE._serialized_end=294
|
||||
_GETMILLISECONDSRESPONSE._serialized_start=296
|
||||
_GETMILLISECONDSRESPONSE._serialized_end=343
|
||||
_SERVESEGMENTS._serialized_start=346
|
||||
_SERVESEGMENTS._serialized_end=590
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
53
src/funnel/stubs/serve_segments_pb2.pyi
Normal file
53
src/funnel/stubs/serve_segments_pb2.pyi
Normal file
@ -0,0 +1,53 @@
|
||||
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 GetHoursRequest(_message.Message):
|
||||
__slots__ = ["timezone"]
|
||||
TIMEZONE_FIELD_NUMBER: _ClassVar[int]
|
||||
timezone: str
|
||||
def __init__(self, timezone: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class GetHoursResponse(_message.Message):
|
||||
__slots__ = ["hours"]
|
||||
HOURS_FIELD_NUMBER: _ClassVar[int]
|
||||
hours: int
|
||||
def __init__(self, hours: _Optional[int] = ...) -> None: ...
|
||||
|
||||
class GetMillisecondsRequest(_message.Message):
|
||||
__slots__ = ["timezone"]
|
||||
TIMEZONE_FIELD_NUMBER: _ClassVar[int]
|
||||
timezone: str
|
||||
def __init__(self, timezone: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class GetMillisecondsResponse(_message.Message):
|
||||
__slots__ = ["milliseconds"]
|
||||
MILLISECONDS_FIELD_NUMBER: _ClassVar[int]
|
||||
milliseconds: int
|
||||
def __init__(self, milliseconds: _Optional[int] = ...) -> None: ...
|
||||
|
||||
class GetMinutesRequest(_message.Message):
|
||||
__slots__ = ["timezone"]
|
||||
TIMEZONE_FIELD_NUMBER: _ClassVar[int]
|
||||
timezone: str
|
||||
def __init__(self, timezone: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class GetMinutesResponse(_message.Message):
|
||||
__slots__ = ["minutes"]
|
||||
MINUTES_FIELD_NUMBER: _ClassVar[int]
|
||||
minutes: int
|
||||
def __init__(self, minutes: _Optional[int] = ...) -> None: ...
|
||||
|
||||
class GetSecondsRequest(_message.Message):
|
||||
__slots__ = ["timezone"]
|
||||
TIMEZONE_FIELD_NUMBER: _ClassVar[int]
|
||||
timezone: str
|
||||
def __init__(self, timezone: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class GetSecondsResponse(_message.Message):
|
||||
__slots__ = ["seconds"]
|
||||
SECONDS_FIELD_NUMBER: _ClassVar[int]
|
||||
seconds: int
|
||||
def __init__(self, seconds: _Optional[int] = ...) -> None: ...
|
||||
165
src/funnel/stubs/serve_segments_pb2_grpc.py
Normal file
165
src/funnel/stubs/serve_segments_pb2_grpc.py
Normal file
@ -0,0 +1,165 @@
|
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
||||
"""Client and server classes corresponding to protobuf-defined services."""
|
||||
import grpc
|
||||
|
||||
from . import serve_segments_pb2 as serve__segments__pb2
|
||||
|
||||
|
||||
class ServeSegmentsStub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.GetHours = channel.unary_unary(
|
||||
'/ServeSegments/GetHours',
|
||||
request_serializer=serve__segments__pb2.GetHoursRequest.SerializeToString,
|
||||
response_deserializer=serve__segments__pb2.GetHoursResponse.FromString,
|
||||
)
|
||||
self.GetMinutes = channel.unary_unary(
|
||||
'/ServeSegments/GetMinutes',
|
||||
request_serializer=serve__segments__pb2.GetMinutesRequest.SerializeToString,
|
||||
response_deserializer=serve__segments__pb2.GetMinutesResponse.FromString,
|
||||
)
|
||||
self.GetSeconds = channel.unary_unary(
|
||||
'/ServeSegments/GetSeconds',
|
||||
request_serializer=serve__segments__pb2.GetSecondsRequest.SerializeToString,
|
||||
response_deserializer=serve__segments__pb2.GetSecondsResponse.FromString,
|
||||
)
|
||||
self.GetMilliseconds = channel.unary_unary(
|
||||
'/ServeSegments/GetMilliseconds',
|
||||
request_serializer=serve__segments__pb2.GetMillisecondsRequest.SerializeToString,
|
||||
response_deserializer=serve__segments__pb2.GetMillisecondsResponse.FromString,
|
||||
)
|
||||
|
||||
|
||||
class ServeSegmentsServicer(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def GetHours(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 GetMinutes(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 GetSeconds(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 GetMilliseconds(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_ServeSegmentsServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'GetHours': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetHours,
|
||||
request_deserializer=serve__segments__pb2.GetHoursRequest.FromString,
|
||||
response_serializer=serve__segments__pb2.GetHoursResponse.SerializeToString,
|
||||
),
|
||||
'GetMinutes': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetMinutes,
|
||||
request_deserializer=serve__segments__pb2.GetMinutesRequest.FromString,
|
||||
response_serializer=serve__segments__pb2.GetMinutesResponse.SerializeToString,
|
||||
),
|
||||
'GetSeconds': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetSeconds,
|
||||
request_deserializer=serve__segments__pb2.GetSecondsRequest.FromString,
|
||||
response_serializer=serve__segments__pb2.GetSecondsResponse.SerializeToString,
|
||||
),
|
||||
'GetMilliseconds': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetMilliseconds,
|
||||
request_deserializer=serve__segments__pb2.GetMillisecondsRequest.FromString,
|
||||
response_serializer=serve__segments__pb2.GetMillisecondsResponse.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'ServeSegments', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
class ServeSegments(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
@staticmethod
|
||||
def GetHours(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, '/ServeSegments/GetHours',
|
||||
serve__segments__pb2.GetHoursRequest.SerializeToString,
|
||||
serve__segments__pb2.GetHoursResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def GetMinutes(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, '/ServeSegments/GetMinutes',
|
||||
serve__segments__pb2.GetMinutesRequest.SerializeToString,
|
||||
serve__segments__pb2.GetMinutesResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def GetSeconds(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, '/ServeSegments/GetSeconds',
|
||||
serve__segments__pb2.GetSecondsRequest.SerializeToString,
|
||||
serve__segments__pb2.GetSecondsResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def GetMilliseconds(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, '/ServeSegments/GetMilliseconds',
|
||||
serve__segments__pb2.GetMillisecondsRequest.SerializeToString,
|
||||
serve__segments__pb2.GetMillisecondsResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
36
src/funnel/ws_server.py
Normal file
36
src/funnel/ws_server.py
Normal file
@ -0,0 +1,36 @@
|
||||
import asyncio
|
||||
from websockets.legacy.protocol import broadcast
|
||||
from websockets.legacy.server import serve as ws_serve
|
||||
from websockets.server import WebSocketServerProtocol
|
||||
|
||||
WS_HOST = "localhost"
|
||||
WS_PORT = 50010
|
||||
|
||||
connected_clients = set()
|
||||
|
||||
|
||||
async def ws_handler(websocket: WebSocketServerProtocol):
|
||||
connected_clients.add(websocket)
|
||||
print("Client added: ", websocket)
|
||||
|
||||
try:
|
||||
async for message in websocket:
|
||||
broadcast(connected_clients, message)
|
||||
# await websocket.send(f"Are you talking to me? {message}")
|
||||
finally:
|
||||
connected_clients.remove(websocket)
|
||||
print("Client removed: ", websocket)
|
||||
|
||||
|
||||
async def main():
|
||||
print(f"Starting WS server on {WS_HOST}:{WS_PORT}")
|
||||
async with ws_serve(
|
||||
ws_handler=ws_handler,
|
||||
host=WS_HOST,
|
||||
port=WS_PORT,
|
||||
):
|
||||
await asyncio.Future() # run forever
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@ -1,6 +1,8 @@
|
||||
syntax = "proto3";
|
||||
package serve_currenttime;
|
||||
option go_package = "example.com/project/protos/serve_currenttime";
|
||||
|
||||
service ServeCurrentTime {
|
||||
service ServeCurrentTimeService {
|
||||
rpc GetCurrentTime(GetCurrentTimeRequest) returns (GetCurrentTimeResponse);
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "example.com/project/protos/serve_hours";
|
||||
|
||||
service ServeHours { rpc GetHours(GetHoursRequest) returns (GetHoursResponse); }
|
||||
|
||||
message GetHoursRequest { string timezone = 1; }
|
||||
|
||||
message GetHoursResponse { uint32 hours = 1; }
|
||||
@ -1,9 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
service ServeMilliseconds {
|
||||
rpc GetMilliseconds(GetMillisecondsRequest) returns (GetMillisecondsResponse);
|
||||
}
|
||||
|
||||
message GetMillisecondsRequest { string timezone = 1; }
|
||||
|
||||
message GetMillisecondsResponse { uint32 milliseconds = 1; }
|
||||
@ -1,9 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
service ServeMinutes {
|
||||
rpc GetMinutes(GetMinutesRequest) returns (GetMinutesResponse);
|
||||
}
|
||||
|
||||
message GetMinutesRequest { string timezone = 1; }
|
||||
|
||||
message GetMinutesResponse { uint32 minutes = 1; }
|
||||
@ -1,9 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
service ServeSeconds {
|
||||
rpc GetSeconds(GetSecondsRequest) returns (GetSecondsResponse);
|
||||
}
|
||||
|
||||
message GetSecondsRequest { string timezone = 1; }
|
||||
|
||||
message GetSecondsResponse { uint32 seconds = 1; }
|
||||
20
src/protos/serve_segments.proto
Normal file
20
src/protos/serve_segments.proto
Normal file
@ -0,0 +1,20 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "example.com/project/protos/serve_segments";
|
||||
|
||||
service ServeSegments {
|
||||
rpc GetHours(GetHoursRequest) returns (GetHoursResponse);
|
||||
rpc GetMinutes(GetMinutesRequest) returns (GetMinutesResponse);
|
||||
rpc GetSeconds(GetSecondsRequest) returns (GetSecondsResponse);
|
||||
rpc GetMilliseconds(GetMillisecondsRequest) returns (GetMillisecondsResponse);
|
||||
}
|
||||
|
||||
message GetHoursRequest { string timezone = 1; }
|
||||
message GetMinutesRequest { string timezone = 1; }
|
||||
message GetSecondsRequest { string timezone = 1; }
|
||||
message GetMillisecondsRequest { string timezone = 1; }
|
||||
|
||||
message GetHoursResponse { uint32 hours = 1; }
|
||||
message GetMinutesResponse { uint32 minutes = 1; }
|
||||
message GetSecondsResponse { uint32 seconds = 1; }
|
||||
message GetMillisecondsResponse { uint32 milliseconds = 1; }
|
||||
7
src/serve_currenttime/Cargo.lock
generated
7
src/serve_currenttime/Cargo.lock
generated
@ -1,7 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "serve_currenttime"
|
||||
version = "0.1.0"
|
||||
13
src/serve_currenttime/Makefile
Normal file
13
src/serve_currenttime/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
PROTO_DIR=../protos
|
||||
STUBS_DIR=./stubs
|
||||
PROTO_FILENAME=serve_currenttime.proto
|
||||
|
||||
run:
|
||||
@node main.js
|
||||
|
||||
proto:
|
||||
@npx grpc_tools_node_protoc \
|
||||
-I$(PROTO_DIR) \
|
||||
--js_out=import_style=commonjs,binary:$(STUBS_DIR) \
|
||||
--grpc_out=grpc_js:$(STUBS_DIR) \
|
||||
$(PROTO_DIR)/$(PROTO_FILENAME)
|
||||
52
src/serve_currenttime/main.js
Normal file
52
src/serve_currenttime/main.js
Normal file
@ -0,0 +1,52 @@
|
||||
import { loadPackageDefinition, Server, ServerCredentials } from "@grpc/grpc-js";
|
||||
import { loadSync } from "@grpc/proto-loader";
|
||||
import utc from "dayjs/plugin/utc.js";
|
||||
import timezone from "dayjs/plugin/timezone.js";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
const SERVE_CURRENTTIME_HOST = "localhost";
|
||||
const SERVE_CURRENTTIME_PORT = 50000;
|
||||
const PROTO_PATH = "../protos/serve_currenttime.proto";
|
||||
|
||||
const PROTO_PACKAGE_OPTIONS = {
|
||||
keepCase: true,
|
||||
longs: String,
|
||||
enums: String,
|
||||
defaults: true,
|
||||
oneofs: true,
|
||||
};
|
||||
|
||||
function getCurrentTime(call, callback) {
|
||||
const timezone = call.request.timezone;
|
||||
const now = dayjs().tz(timezone);
|
||||
|
||||
callback(null, {
|
||||
hours: now.hour(),
|
||||
minutes: now.minute(),
|
||||
seconds: now.second(),
|
||||
milliseconds: now.millisecond(),
|
||||
formatted_time: now.format("YYYY-MM-DDTHH:mm:ss.SSS"),
|
||||
});
|
||||
}
|
||||
|
||||
function main() {
|
||||
var packageDefinition = loadSync(PROTO_PATH, PROTO_PACKAGE_OPTIONS);
|
||||
const serveCurrentTimeProto = loadPackageDefinition(packageDefinition).serve_currenttime;
|
||||
const server = new Server();
|
||||
|
||||
server.addService(serveCurrentTimeProto.ServeCurrentTimeService.service, {
|
||||
getCurrentTime: getCurrentTime,
|
||||
});
|
||||
|
||||
server.bindAsync(`${SERVE_CURRENTTIME_HOST}:${SERVE_CURRENTTIME_PORT}`, ServerCredentials.createInsecure(), () => {
|
||||
console.log(
|
||||
`🖧 Starting ServeCurrentTime NodeJS server on ${SERVE_CURRENTTIME_HOST}:${SERVE_CURRENTTIME_PORT}`
|
||||
);
|
||||
server.start();
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
1534
src/serve_currenttime/package-lock.json
generated
Normal file
1534
src/serve_currenttime/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
src/serve_currenttime/package.json
Normal file
16
src/serve_currenttime/package.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "grpc-examples",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.8.12",
|
||||
"@grpc/proto-loader": "^0.7.5",
|
||||
"async": "^3.2.4",
|
||||
"dayjs": "^1.11.7",
|
||||
"dayjs-timezone-iana-plugin": "^0.1.0",
|
||||
"google-protobuf": "^3.21.2",
|
||||
"grpc-tools": "^1.12.4",
|
||||
"lodash": "^4.17.21",
|
||||
"minimist": "^1.2.8"
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
44
src/serve_currenttime/stubs/serve_currenttime_grpc_pb.js
Normal file
44
src/serve_currenttime/stubs/serve_currenttime_grpc_pb.js
Normal file
@ -0,0 +1,44 @@
|
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
|
||||
'use strict';
|
||||
var grpc = require('@grpc/grpc-js');
|
||||
var serve_currenttime_pb = require('./serve_currenttime_pb.js');
|
||||
|
||||
function serialize_serve_currenttime_GetCurrentTimeRequest(arg) {
|
||||
if (!(arg instanceof serve_currenttime_pb.GetCurrentTimeRequest)) {
|
||||
throw new Error('Expected argument of type serve_currenttime.GetCurrentTimeRequest');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_serve_currenttime_GetCurrentTimeRequest(buffer_arg) {
|
||||
return serve_currenttime_pb.GetCurrentTimeRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_serve_currenttime_GetCurrentTimeResponse(arg) {
|
||||
if (!(arg instanceof serve_currenttime_pb.GetCurrentTimeResponse)) {
|
||||
throw new Error('Expected argument of type serve_currenttime.GetCurrentTimeResponse');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_serve_currenttime_GetCurrentTimeResponse(buffer_arg) {
|
||||
return serve_currenttime_pb.GetCurrentTimeResponse.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
|
||||
var ServeCurrentTimeService = exports.ServeCurrentTimeService = {
|
||||
getCurrentTime: {
|
||||
path: '/serve_currenttime.ServeCurrentTime/GetCurrentTime',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: serve_currenttime_pb.GetCurrentTimeRequest,
|
||||
responseType: serve_currenttime_pb.GetCurrentTimeResponse,
|
||||
requestSerialize: serialize_serve_currenttime_GetCurrentTimeRequest,
|
||||
requestDeserialize: deserialize_serve_currenttime_GetCurrentTimeRequest,
|
||||
responseSerialize: serialize_serve_currenttime_GetCurrentTimeResponse,
|
||||
responseDeserialize: deserialize_serve_currenttime_GetCurrentTimeResponse,
|
||||
},
|
||||
};
|
||||
|
||||
exports.ServeCurrentTimeClient = grpc.makeGenericClientConstructor(ServeCurrentTimeService);
|
||||
448
src/serve_currenttime/stubs/serve_currenttime_pb.js
Normal file
448
src/serve_currenttime/stubs/serve_currenttime_pb.js
Normal file
@ -0,0 +1,448 @@
|
||||
// source: serve_currenttime.proto
|
||||
/**
|
||||
* @fileoverview
|
||||
* @enhanceable
|
||||
* @suppress {missingRequire} reports error on implicit type usages.
|
||||
* @suppress {messageConventions} JS Compiler reports an error if a variable or
|
||||
* field starts with 'MSG_' and isn't a translatable message.
|
||||
* @public
|
||||
*/
|
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
var jspb = require('google-protobuf');
|
||||
var goog = jspb;
|
||||
var global = (function() {
|
||||
if (this) { return this; }
|
||||
if (typeof window !== 'undefined') { return window; }
|
||||
if (typeof global !== 'undefined') { return global; }
|
||||
if (typeof self !== 'undefined') { return self; }
|
||||
return Function('return this')();
|
||||
}.call(null));
|
||||
|
||||
goog.exportSymbol('proto.serve_currenttime.GetCurrentTimeRequest', null, global);
|
||||
goog.exportSymbol('proto.serve_currenttime.GetCurrentTimeResponse', null, global);
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.serve_currenttime.GetCurrentTimeRequest, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
/**
|
||||
* @public
|
||||
* @override
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.displayName = 'proto.serve_currenttime.GetCurrentTimeRequest';
|
||||
}
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.serve_currenttime.GetCurrentTimeResponse, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
/**
|
||||
* @public
|
||||
* @override
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.displayName = 'proto.serve_currenttime.GetCurrentTimeResponse';
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* Optional fields that are not set will be set to undefined.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
|
||||
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
|
||||
* JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.serve_currenttime.GetCurrentTimeRequest.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
|
||||
* the JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.serve_currenttime.GetCurrentTimeRequest} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
timezone: jspb.Message.getFieldWithDefault(msg, 1, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeRequest}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.serve_currenttime.GetCurrentTimeRequest;
|
||||
return proto.serve_currenttime.GetCurrentTimeRequest.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.serve_currenttime.GetCurrentTimeRequest} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeRequest}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setTimezone(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.serializeBinaryToWriter(this, writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the given message to binary data (in protobuf wire
|
||||
* format), writing to the given BinaryWriter.
|
||||
* @param {!proto.serve_currenttime.GetCurrentTimeRequest} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.serializeBinaryToWriter = function(message, writer) {
|
||||
var f = undefined;
|
||||
f = message.getTimezone();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string timezone = 1;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.prototype.getTimezone = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeRequest} returns this
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeRequest.prototype.setTimezone = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* Optional fields that are not set will be set to undefined.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
|
||||
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
|
||||
* JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.serve_currenttime.GetCurrentTimeResponse.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
|
||||
* the JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.serve_currenttime.GetCurrentTimeResponse} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
hours: jspb.Message.getFieldWithDefault(msg, 1, 0),
|
||||
minutes: jspb.Message.getFieldWithDefault(msg, 2, 0),
|
||||
seconds: jspb.Message.getFieldWithDefault(msg, 3, 0),
|
||||
milliseconds: jspb.Message.getFieldWithDefault(msg, 4, 0),
|
||||
formattedTime: jspb.Message.getFieldWithDefault(msg, 5, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeResponse}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.serve_currenttime.GetCurrentTimeResponse;
|
||||
return proto.serve_currenttime.GetCurrentTimeResponse.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.serve_currenttime.GetCurrentTimeResponse} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeResponse}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = /** @type {number} */ (reader.readUint32());
|
||||
msg.setHours(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {number} */ (reader.readUint32());
|
||||
msg.setMinutes(value);
|
||||
break;
|
||||
case 3:
|
||||
var value = /** @type {number} */ (reader.readUint32());
|
||||
msg.setSeconds(value);
|
||||
break;
|
||||
case 4:
|
||||
var value = /** @type {number} */ (reader.readUint32());
|
||||
msg.setMilliseconds(value);
|
||||
break;
|
||||
case 5:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setFormattedTime(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.serializeBinaryToWriter(this, writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the given message to binary data (in protobuf wire
|
||||
* format), writing to the given BinaryWriter.
|
||||
* @param {!proto.serve_currenttime.GetCurrentTimeResponse} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.serializeBinaryToWriter = function(message, writer) {
|
||||
var f = undefined;
|
||||
f = message.getHours();
|
||||
if (f !== 0) {
|
||||
writer.writeUint32(
|
||||
1,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getMinutes();
|
||||
if (f !== 0) {
|
||||
writer.writeUint32(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getSeconds();
|
||||
if (f !== 0) {
|
||||
writer.writeUint32(
|
||||
3,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getMilliseconds();
|
||||
if (f !== 0) {
|
||||
writer.writeUint32(
|
||||
4,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getFormattedTime();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
5,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint32 hours = 1;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.getHours = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeResponse} returns this
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.setHours = function(value) {
|
||||
return jspb.Message.setProto3IntField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint32 minutes = 2;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.getMinutes = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeResponse} returns this
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.setMinutes = function(value) {
|
||||
return jspb.Message.setProto3IntField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint32 seconds = 3;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.getSeconds = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeResponse} returns this
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.setSeconds = function(value) {
|
||||
return jspb.Message.setProto3IntField(this, 3, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional uint32 milliseconds = 4;
|
||||
* @return {number}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.getMilliseconds = function() {
|
||||
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeResponse} returns this
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.setMilliseconds = function(value) {
|
||||
return jspb.Message.setProto3IntField(this, 4, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string formatted_time = 5;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.getFormattedTime = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.serve_currenttime.GetCurrentTimeResponse} returns this
|
||||
*/
|
||||
proto.serve_currenttime.GetCurrentTimeResponse.prototype.setFormattedTime = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 5, value);
|
||||
};
|
||||
|
||||
|
||||
goog.object.extend(exports, proto.serve_currenttime);
|
||||
1072
src/serve_currenttime_rust/Cargo.lock
generated
Normal file
1072
src/serve_currenttime_rust/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,14 @@ edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
[[bin]]
|
||||
name = "server"
|
||||
path = "src/server.rs"
|
||||
name = "serve_currenttime"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
tonic = "0.8"
|
||||
prost = "0.11"
|
||||
tokio = { version = "1.19.2", features = ["macros", "rt-multi-thread"] }
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.8"
|
||||
2
src/serve_currenttime_rust/Makefile
Normal file
2
src/serve_currenttime_rust/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
run:
|
||||
cargo run --bin serve_currenttime
|
||||
4
src/serve_currenttime_rust/build.rs
Normal file
4
src/serve_currenttime_rust/build.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
tonic_build::compile_protos("../protos/serve_currenttime.proto")?;
|
||||
Ok(())
|
||||
}
|
||||
61
src/serve_currenttime_rust/src/main.rs
Normal file
61
src/serve_currenttime_rust/src/main.rs
Normal file
@ -0,0 +1,61 @@
|
||||
use serve_currenttime::{
|
||||
serve_current_time_server::{ServeCurrentTime, ServeCurrentTimeServer},
|
||||
GetCurrentTimeRequest, GetCurrentTimeResponse,
|
||||
};
|
||||
|
||||
// use serve_currenttime::{
|
||||
// serve_currenttime_server::{ServeCurrentTime, ServeCurrentTimeServer},
|
||||
// GetCurrentTimeRequest, GetCurrentTimeResponse,
|
||||
// };
|
||||
|
||||
use tonic::{transport::Server, Request, Response, Status};
|
||||
|
||||
pub mod serve_currenttime {
|
||||
tonic::include_proto!("serve_currenttime");
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let address = "[::1]:8080".parse().unwrap();
|
||||
let voting_service = ServeCurrentTimeService::default();
|
||||
|
||||
Server::builder()
|
||||
.add_service(ServeCurrentTimeServer::new(voting_service))
|
||||
.serve(address)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ServeCurrentTimeService {}
|
||||
|
||||
#[tonic::async_trait]
|
||||
impl ServeCurrentTime for ServeCurrentTimeService {
|
||||
async fn get_current_time(
|
||||
&self,
|
||||
request: Request<GetCurrentTimeRequest>,
|
||||
) -> Result<Response<GetCurrentTimeResponse>, Status> {
|
||||
let r = request.into_inner();
|
||||
|
||||
Ok(Response::new(GetCurrentTimeResponse {
|
||||
formatted_time: "xxx".to_string(),
|
||||
hours: 11,
|
||||
minutes: 22,
|
||||
seconds: 33,
|
||||
milliseconds: 44,
|
||||
}))
|
||||
|
||||
// match r.vote {
|
||||
// 0 => Ok(Response::new(serve_currenttime::GetCurrentTimeResponse {
|
||||
// confirmation: { format!("Happy to confirm that you upvoted for {}", r.url) },
|
||||
// })),
|
||||
// 1 => Ok(Response::new(serve_currenttime::GetCurrentTimeResponse {
|
||||
// confirmation: { format!("Confirmation that you downvoted for {}", r.url) },
|
||||
// })),
|
||||
// _ => Err(Status::new(
|
||||
// tonic::Code::OutOfRange,
|
||||
// "Invalid vote provided",
|
||||
// )),
|
||||
// }
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
PROTO_DIR=../protos
|
||||
STUBS_DIR=./stubs
|
||||
PROTO_FILENAME=serve_hours.proto
|
||||
GO_BIN_DIR=/home/eden/go/bin
|
||||
OUT_DIR=../../dist
|
||||
OUT_FILENAME=serve_hours
|
||||
|
||||
run:
|
||||
@go run ./main.go
|
||||
|
||||
build:
|
||||
@go build -ldflags "-s -w" -o $(OUT_DIR)/${OUT_FILENAME} ./main.go
|
||||
|
||||
proto:
|
||||
@PATH="$(PATH):$(GO_BIN_DIR)" \
|
||||
protoc \
|
||||
-I$(PROTO_DIR) \
|
||||
--go_out=$(STUBS_DIR) \
|
||||
--go_opt=paths=source_relative \
|
||||
--go-grpc_out=$(STUBS_DIR) \
|
||||
--go-grpc_opt=paths=source_relative \
|
||||
$(PROTO_DIR)/$(PROTO_FILENAME)
|
||||
@ -1,47 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
pb "serve_hours/stubs"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
const SERVE_HOURS_HOST = "localhost"
|
||||
const SERVE_HOURS_PORT = 50001
|
||||
const SERVE_MINUTES_HOST = "localhost"
|
||||
const SERVE_MINUTES_PORT = 50002
|
||||
const SERVE_SECONDS_HOST = "localhost"
|
||||
const SERVE_SECONDS_PORT = 50003
|
||||
const SERVE_MILLISECONDS_HOST = "localhost"
|
||||
const SERVE_MILLISECONDS_PORT = 50004
|
||||
|
||||
type grpc_server struct {
|
||||
pb.UnimplementedServeHoursServer
|
||||
}
|
||||
|
||||
func (s *grpc_server) GetHours(ctx context.Context, in *pb.GetHoursRequest) (*pb.GetHoursResponse, error) {
|
||||
log.Printf("Received timezone: %v", in.GetTimezone())
|
||||
return &pb.GetHoursResponse{Hours: 123}, nil
|
||||
}
|
||||
|
||||
func serve() {
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", SERVE_HOURS_HOST, SERVE_HOURS_PORT))
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
s := grpc.NewServer()
|
||||
pb.RegisterServeHoursServer(s, &grpc_server{})
|
||||
log.Printf("server listening at %v", lis.Addr())
|
||||
if err := s.Serve(lis); err != nil {
|
||||
log.Fatalf("failed to serve: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
serve()
|
||||
}
|
||||
@ -1,212 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.12
|
||||
// source: serve_hours.proto
|
||||
|
||||
package serve_hours
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type GetHoursRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Timezone string `protobuf:"bytes,1,opt,name=timezone,proto3" json:"timezone,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetHoursRequest) Reset() {
|
||||
*x = GetHoursRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_hours_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetHoursRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetHoursRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetHoursRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_hours_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetHoursRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetHoursRequest) Descriptor() ([]byte, []int) {
|
||||
return file_serve_hours_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GetHoursRequest) GetTimezone() string {
|
||||
if x != nil {
|
||||
return x.Timezone
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetHoursResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Hours uint32 `protobuf:"varint,1,opt,name=hours,proto3" json:"hours,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetHoursResponse) Reset() {
|
||||
*x = GetHoursResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_hours_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetHoursResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetHoursResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetHoursResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_hours_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetHoursResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetHoursResponse) Descriptor() ([]byte, []int) {
|
||||
return file_serve_hours_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetHoursResponse) GetHours() uint32 {
|
||||
if x != nil {
|
||||
return x.Hours
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_serve_hours_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_serve_hours_proto_rawDesc = []byte{
|
||||
0x0a, 0x11, 0x73, 0x65, 0x72, 0x76, 0x65, 0x5f, 0x68, 0x6f, 0x75, 0x72, 0x73, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x22, 0x2d, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x48, 0x6f, 0x75, 0x72, 0x73, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f,
|
||||
0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f,
|
||||
0x6e, 0x65, 0x22, 0x28, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x48, 0x6f, 0x75, 0x72, 0x73, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x68, 0x6f, 0x75, 0x72, 0x73, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x68, 0x6f, 0x75, 0x72, 0x73, 0x32, 0x3d, 0x0a, 0x0a,
|
||||
0x53, 0x65, 0x72, 0x76, 0x65, 0x48, 0x6f, 0x75, 0x72, 0x73, 0x12, 0x2f, 0x0a, 0x08, 0x47, 0x65,
|
||||
0x74, 0x48, 0x6f, 0x75, 0x72, 0x73, 0x12, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x48, 0x6f, 0x75, 0x72,
|
||||
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x47, 0x65, 0x74, 0x48, 0x6f,
|
||||
0x75, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x28, 0x5a, 0x26, 0x65,
|
||||
0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x5f,
|
||||
0x68, 0x6f, 0x75, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_serve_hours_proto_rawDescOnce sync.Once
|
||||
file_serve_hours_proto_rawDescData = file_serve_hours_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_serve_hours_proto_rawDescGZIP() []byte {
|
||||
file_serve_hours_proto_rawDescOnce.Do(func() {
|
||||
file_serve_hours_proto_rawDescData = protoimpl.X.CompressGZIP(file_serve_hours_proto_rawDescData)
|
||||
})
|
||||
return file_serve_hours_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_serve_hours_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_serve_hours_proto_goTypes = []interface{}{
|
||||
(*GetHoursRequest)(nil), // 0: GetHoursRequest
|
||||
(*GetHoursResponse)(nil), // 1: GetHoursResponse
|
||||
}
|
||||
var file_serve_hours_proto_depIdxs = []int32{
|
||||
0, // 0: ServeHours.GetHours:input_type -> GetHoursRequest
|
||||
1, // 1: ServeHours.GetHours:output_type -> GetHoursResponse
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_serve_hours_proto_init() }
|
||||
func file_serve_hours_proto_init() {
|
||||
if File_serve_hours_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_serve_hours_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetHoursRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_serve_hours_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetHoursResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_serve_hours_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_serve_hours_proto_goTypes,
|
||||
DependencyIndexes: file_serve_hours_proto_depIdxs,
|
||||
MessageInfos: file_serve_hours_proto_msgTypes,
|
||||
}.Build()
|
||||
File_serve_hours_proto = out.File
|
||||
file_serve_hours_proto_rawDesc = nil
|
||||
file_serve_hours_proto_goTypes = nil
|
||||
file_serve_hours_proto_depIdxs = nil
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.21.12
|
||||
// source: serve_hours.proto
|
||||
|
||||
package serve_hours
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// ServeHoursClient is the client API for ServeHours service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type ServeHoursClient interface {
|
||||
GetHours(ctx context.Context, in *GetHoursRequest, opts ...grpc.CallOption) (*GetHoursResponse, error)
|
||||
}
|
||||
|
||||
type serveHoursClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewServeHoursClient(cc grpc.ClientConnInterface) ServeHoursClient {
|
||||
return &serveHoursClient{cc}
|
||||
}
|
||||
|
||||
func (c *serveHoursClient) GetHours(ctx context.Context, in *GetHoursRequest, opts ...grpc.CallOption) (*GetHoursResponse, error) {
|
||||
out := new(GetHoursResponse)
|
||||
err := c.cc.Invoke(ctx, "/ServeHours/GetHours", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ServeHoursServer is the server API for ServeHours service.
|
||||
// All implementations must embed UnimplementedServeHoursServer
|
||||
// for forward compatibility
|
||||
type ServeHoursServer interface {
|
||||
GetHours(context.Context, *GetHoursRequest) (*GetHoursResponse, error)
|
||||
mustEmbedUnimplementedServeHoursServer()
|
||||
}
|
||||
|
||||
// UnimplementedServeHoursServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedServeHoursServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedServeHoursServer) GetHours(context.Context, *GetHoursRequest) (*GetHoursResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetHours not implemented")
|
||||
}
|
||||
func (UnimplementedServeHoursServer) mustEmbedUnimplementedServeHoursServer() {}
|
||||
|
||||
// UnsafeServeHoursServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ServeHoursServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeServeHoursServer interface {
|
||||
mustEmbedUnimplementedServeHoursServer()
|
||||
}
|
||||
|
||||
func RegisterServeHoursServer(s grpc.ServiceRegistrar, srv ServeHoursServer) {
|
||||
s.RegisterService(&ServeHours_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _ServeHours_GetHours_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetHoursRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ServeHoursServer).GetHours(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ServeHours/GetHours",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ServeHoursServer).GetHours(ctx, req.(*GetHoursRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// ServeHours_ServiceDesc is the grpc.ServiceDesc for ServeHours service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var ServeHours_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "ServeHours",
|
||||
HandlerType: (*ServeHoursServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetHours",
|
||||
Handler: _ServeHours_GetHours_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "serve_hours.proto",
|
||||
}
|
||||
30
src/serve_segments/Makefile
Normal file
30
src/serve_segments/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
PROTO_DIR=../protos
|
||||
STUBS_DIR=./stubs
|
||||
GO_BIN_DIR=/home/eden/go/bin
|
||||
OUT_DIR=../../dist
|
||||
OUT_FILENAME=serve_segments
|
||||
|
||||
run:
|
||||
@go run ./main.go
|
||||
|
||||
build:
|
||||
@go build -ldflags "-s -w" -o $(OUT_DIR)/${OUT_FILENAME} ./main.go
|
||||
|
||||
proto:
|
||||
@PATH="$(PATH):$(GO_BIN_DIR)" \
|
||||
protoc \
|
||||
-I$(PROTO_DIR) \
|
||||
--go_out=$(STUBS_DIR)/serve_segments \
|
||||
--go-grpc_out=$(STUBS_DIR)/serve_segments \
|
||||
--go_opt=paths=source_relative \
|
||||
--go-grpc_opt=paths=source_relative \
|
||||
$(PROTO_DIR)/serve_segments.proto
|
||||
|
||||
@PATH="$(PATH):$(GO_BIN_DIR)" \
|
||||
protoc \
|
||||
-I$(PROTO_DIR) \
|
||||
--go_out=$(STUBS_DIR)/serve_currenttime \
|
||||
--go-grpc_out=$(STUBS_DIR)/serve_currenttime \
|
||||
--go_opt=paths=source_relative \
|
||||
--go-grpc_opt=paths=source_relative \
|
||||
$(PROTO_DIR)/serve_currenttime.proto
|
||||
@ -1,4 +1,4 @@
|
||||
module serve_hours
|
||||
module serve_segments
|
||||
|
||||
go 1.20
|
||||
|
||||
122
src/serve_segments/main.go
Normal file
122
src/serve_segments/main.go
Normal file
@ -0,0 +1,122 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
pb_get_currenttime "serve_segments/stubs/serve_currenttime"
|
||||
pb_serve_segments "serve_segments/stubs/serve_segments"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
const SERVE_CURRENTTIME_HOST = "localhost"
|
||||
const SERVE_CURRENTTIME_PORT = 50000
|
||||
const SERVE_SEGMENTS_HOST = "localhost"
|
||||
const SERVE_SEGMENTS_PORT = 50001
|
||||
|
||||
type grpc_server struct {
|
||||
pb_serve_segments.UnimplementedServeSegmentsServer
|
||||
}
|
||||
|
||||
type currentTimeResponse struct {
|
||||
hours uint32
|
||||
minutes uint32
|
||||
seconds uint32
|
||||
milliseconds uint32
|
||||
formatted_time string
|
||||
}
|
||||
|
||||
var serveCurrentTimeServiceClient pb_get_currenttime.ServeCurrentTimeServiceClient
|
||||
|
||||
func GetCurrentTime(timezone string) currentTimeResponse {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
r, err := serveCurrentTimeServiceClient.GetCurrentTime(
|
||||
ctx,
|
||||
&pb_get_currenttime.GetCurrentTimeRequest{Timezone: timezone},
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("could not greet: %v", err)
|
||||
}
|
||||
|
||||
return currentTimeResponse{
|
||||
hours: r.Hours,
|
||||
minutes: r.Minutes,
|
||||
seconds: r.Seconds,
|
||||
milliseconds: r.Milliseconds,
|
||||
formatted_time: r.FormattedTime,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *grpc_server) GetHours(
|
||||
ctx context.Context,
|
||||
in *pb_serve_segments.GetHoursRequest,
|
||||
) (*pb_serve_segments.GetHoursResponse, error) {
|
||||
timezone := in.GetTimezone()
|
||||
current_time := GetCurrentTime(timezone)
|
||||
return &pb_serve_segments.GetHoursResponse{Hours: current_time.hours}, nil
|
||||
}
|
||||
|
||||
func (s *grpc_server) GetMinutes(
|
||||
ctx context.Context,
|
||||
in *pb_serve_segments.GetMinutesRequest,
|
||||
) (*pb_serve_segments.GetMinutesResponse, error) {
|
||||
timezone := in.GetTimezone()
|
||||
current_time := GetCurrentTime(timezone)
|
||||
return &pb_serve_segments.GetMinutesResponse{Minutes: current_time.minutes}, nil
|
||||
}
|
||||
|
||||
func (s *grpc_server) GetSeconds(
|
||||
ctx context.Context,
|
||||
in *pb_serve_segments.GetSecondsRequest,
|
||||
) (*pb_serve_segments.GetSecondsResponse, error) {
|
||||
timezone := in.GetTimezone()
|
||||
current_time := GetCurrentTime(timezone)
|
||||
return &pb_serve_segments.GetSecondsResponse{Seconds: current_time.seconds}, nil
|
||||
}
|
||||
|
||||
func (s *grpc_server) GetMilliseconds(
|
||||
ctx context.Context,
|
||||
in *pb_serve_segments.GetMillisecondsRequest,
|
||||
) (*pb_serve_segments.GetMillisecondsResponse, error) {
|
||||
timezone := in.GetTimezone()
|
||||
current_time := GetCurrentTime(timezone)
|
||||
return &pb_serve_segments.GetMillisecondsResponse{Milliseconds: current_time.milliseconds}, nil
|
||||
}
|
||||
|
||||
func serve() {
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", SERVE_SEGMENTS_HOST, SERVE_SEGMENTS_PORT))
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
|
||||
// create ServeSegments server
|
||||
server := grpc.NewServer()
|
||||
pb_serve_segments.RegisterServeSegmentsServer(server, &grpc_server{})
|
||||
log.Printf("🖧 Starting ServeSegments Go server on %v", lis.Addr())
|
||||
|
||||
// create connection to ServeCurrentTime server
|
||||
getCurrentTimeConn, err := grpc.Dial(
|
||||
fmt.Sprintf("%s:%d", SERVE_CURRENTTIME_HOST, SERVE_CURRENTTIME_PORT),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
defer getCurrentTimeConn.Close()
|
||||
// create client
|
||||
serveCurrentTimeServiceClient = pb_get_currenttime.NewServeCurrentTimeServiceClient(getCurrentTimeConn)
|
||||
|
||||
if err := server.Serve(lis); err != nil {
|
||||
log.Fatalf("failed to serve: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
serve()
|
||||
}
|
||||
@ -0,0 +1,259 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.12
|
||||
// source: serve_currenttime.proto
|
||||
|
||||
package serve_currenttime
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type GetCurrentTimeRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Timezone string `protobuf:"bytes,1,opt,name=timezone,proto3" json:"timezone,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeRequest) Reset() {
|
||||
*x = GetCurrentTimeRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_currenttime_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetCurrentTimeRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetCurrentTimeRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_currenttime_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetCurrentTimeRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetCurrentTimeRequest) Descriptor() ([]byte, []int) {
|
||||
return file_serve_currenttime_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeRequest) GetTimezone() string {
|
||||
if x != nil {
|
||||
return x.Timezone
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetCurrentTimeResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Hours uint32 `protobuf:"varint,1,opt,name=hours,proto3" json:"hours,omitempty"`
|
||||
Minutes uint32 `protobuf:"varint,2,opt,name=minutes,proto3" json:"minutes,omitempty"`
|
||||
Seconds uint32 `protobuf:"varint,3,opt,name=seconds,proto3" json:"seconds,omitempty"`
|
||||
Milliseconds uint32 `protobuf:"varint,4,opt,name=milliseconds,proto3" json:"milliseconds,omitempty"`
|
||||
FormattedTime string `protobuf:"bytes,5,opt,name=formatted_time,json=formattedTime,proto3" json:"formatted_time,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeResponse) Reset() {
|
||||
*x = GetCurrentTimeResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_currenttime_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetCurrentTimeResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetCurrentTimeResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_currenttime_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetCurrentTimeResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetCurrentTimeResponse) Descriptor() ([]byte, []int) {
|
||||
return file_serve_currenttime_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeResponse) GetHours() uint32 {
|
||||
if x != nil {
|
||||
return x.Hours
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeResponse) GetMinutes() uint32 {
|
||||
if x != nil {
|
||||
return x.Minutes
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeResponse) GetSeconds() uint32 {
|
||||
if x != nil {
|
||||
return x.Seconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeResponse) GetMilliseconds() uint32 {
|
||||
if x != nil {
|
||||
return x.Milliseconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetCurrentTimeResponse) GetFormattedTime() string {
|
||||
if x != nil {
|
||||
return x.FormattedTime
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_serve_currenttime_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_serve_currenttime_proto_rawDesc = []byte{
|
||||
0x0a, 0x17, 0x73, 0x65, 0x72, 0x76, 0x65, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x74,
|
||||
0x69, 0x6d, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x73, 0x65, 0x72, 0x76, 0x65,
|
||||
0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x33, 0x0a, 0x15,
|
||||
0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e,
|
||||
0x65, 0x22, 0xad, 0x01, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74,
|
||||
0x54, 0x69, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05,
|
||||
0x68, 0x6f, 0x75, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x68, 0x6f, 0x75,
|
||||
0x72, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x69, 0x6e, 0x75, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0d, 0x52, 0x07, 0x6d, 0x69, 0x6e, 0x75, 0x74, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x73,
|
||||
0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73,
|
||||
0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x6d, 0x69,
|
||||
0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x66, 0x6f,
|
||||
0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0d, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d,
|
||||
0x65, 0x32, 0x80, 0x01, 0x0a, 0x17, 0x53, 0x65, 0x72, 0x76, 0x65, 0x43, 0x75, 0x72, 0x72, 0x65,
|
||||
0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x65, 0x0a,
|
||||
0x0e, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12,
|
||||
0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x74,
|
||||
0x69, 0x6d, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69,
|
||||
0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x73, 0x65, 0x72, 0x76,
|
||||
0x65, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x47, 0x65,
|
||||
0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_serve_currenttime_proto_rawDescOnce sync.Once
|
||||
file_serve_currenttime_proto_rawDescData = file_serve_currenttime_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_serve_currenttime_proto_rawDescGZIP() []byte {
|
||||
file_serve_currenttime_proto_rawDescOnce.Do(func() {
|
||||
file_serve_currenttime_proto_rawDescData = protoimpl.X.CompressGZIP(file_serve_currenttime_proto_rawDescData)
|
||||
})
|
||||
return file_serve_currenttime_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_serve_currenttime_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_serve_currenttime_proto_goTypes = []interface{}{
|
||||
(*GetCurrentTimeRequest)(nil), // 0: serve_currenttime.GetCurrentTimeRequest
|
||||
(*GetCurrentTimeResponse)(nil), // 1: serve_currenttime.GetCurrentTimeResponse
|
||||
}
|
||||
var file_serve_currenttime_proto_depIdxs = []int32{
|
||||
0, // 0: serve_currenttime.ServeCurrentTimeService.GetCurrentTime:input_type -> serve_currenttime.GetCurrentTimeRequest
|
||||
1, // 1: serve_currenttime.ServeCurrentTimeService.GetCurrentTime:output_type -> serve_currenttime.GetCurrentTimeResponse
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_serve_currenttime_proto_init() }
|
||||
func file_serve_currenttime_proto_init() {
|
||||
if File_serve_currenttime_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_serve_currenttime_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetCurrentTimeRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_serve_currenttime_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetCurrentTimeResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_serve_currenttime_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_serve_currenttime_proto_goTypes,
|
||||
DependencyIndexes: file_serve_currenttime_proto_depIdxs,
|
||||
MessageInfos: file_serve_currenttime_proto_msgTypes,
|
||||
}.Build()
|
||||
File_serve_currenttime_proto = out.File
|
||||
file_serve_currenttime_proto_rawDesc = nil
|
||||
file_serve_currenttime_proto_goTypes = nil
|
||||
file_serve_currenttime_proto_depIdxs = nil
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.21.12
|
||||
// source: serve_currenttime.proto
|
||||
|
||||
package serve_currenttime
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// ServeCurrentTimeServiceClient is the client API for ServeCurrentTimeService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type ServeCurrentTimeServiceClient interface {
|
||||
GetCurrentTime(ctx context.Context, in *GetCurrentTimeRequest, opts ...grpc.CallOption) (*GetCurrentTimeResponse, error)
|
||||
}
|
||||
|
||||
type serveCurrentTimeServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewServeCurrentTimeServiceClient(cc grpc.ClientConnInterface) ServeCurrentTimeServiceClient {
|
||||
return &serveCurrentTimeServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *serveCurrentTimeServiceClient) GetCurrentTime(ctx context.Context, in *GetCurrentTimeRequest, opts ...grpc.CallOption) (*GetCurrentTimeResponse, error) {
|
||||
out := new(GetCurrentTimeResponse)
|
||||
err := c.cc.Invoke(ctx, "/serve_currenttime.ServeCurrentTimeService/GetCurrentTime", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ServeCurrentTimeServiceServer is the server API for ServeCurrentTimeService service.
|
||||
// All implementations must embed UnimplementedServeCurrentTimeServiceServer
|
||||
// for forward compatibility
|
||||
type ServeCurrentTimeServiceServer interface {
|
||||
GetCurrentTime(context.Context, *GetCurrentTimeRequest) (*GetCurrentTimeResponse, error)
|
||||
mustEmbedUnimplementedServeCurrentTimeServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedServeCurrentTimeServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedServeCurrentTimeServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedServeCurrentTimeServiceServer) GetCurrentTime(context.Context, *GetCurrentTimeRequest) (*GetCurrentTimeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetCurrentTime not implemented")
|
||||
}
|
||||
func (UnimplementedServeCurrentTimeServiceServer) mustEmbedUnimplementedServeCurrentTimeServiceServer() {
|
||||
}
|
||||
|
||||
// UnsafeServeCurrentTimeServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ServeCurrentTimeServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeServeCurrentTimeServiceServer interface {
|
||||
mustEmbedUnimplementedServeCurrentTimeServiceServer()
|
||||
}
|
||||
|
||||
func RegisterServeCurrentTimeServiceServer(s grpc.ServiceRegistrar, srv ServeCurrentTimeServiceServer) {
|
||||
s.RegisterService(&ServeCurrentTimeService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _ServeCurrentTimeService_GetCurrentTime_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetCurrentTimeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ServeCurrentTimeServiceServer).GetCurrentTime(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/serve_currenttime.ServeCurrentTimeService/GetCurrentTime",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ServeCurrentTimeServiceServer).GetCurrentTime(ctx, req.(*GetCurrentTimeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// ServeCurrentTimeService_ServiceDesc is the grpc.ServiceDesc for ServeCurrentTimeService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var ServeCurrentTimeService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "serve_currenttime.ServeCurrentTimeService",
|
||||
HandlerType: (*ServeCurrentTimeServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetCurrentTime",
|
||||
Handler: _ServeCurrentTimeService_GetCurrentTime_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "serve_currenttime.proto",
|
||||
}
|
||||
610
src/serve_segments/stubs/serve_segments/serve_segments.pb.go
Normal file
610
src/serve_segments/stubs/serve_segments/serve_segments.pb.go
Normal file
@ -0,0 +1,610 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.12
|
||||
// source: serve_segments.proto
|
||||
|
||||
package serve_segments
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type GetHoursRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Timezone string `protobuf:"bytes,1,opt,name=timezone,proto3" json:"timezone,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetHoursRequest) Reset() {
|
||||
*x = GetHoursRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_segments_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetHoursRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetHoursRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetHoursRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_segments_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetHoursRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetHoursRequest) Descriptor() ([]byte, []int) {
|
||||
return file_serve_segments_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GetHoursRequest) GetTimezone() string {
|
||||
if x != nil {
|
||||
return x.Timezone
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetMinutesRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Timezone string `protobuf:"bytes,1,opt,name=timezone,proto3" json:"timezone,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetMinutesRequest) Reset() {
|
||||
*x = GetMinutesRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_segments_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetMinutesRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMinutesRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetMinutesRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_segments_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMinutesRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetMinutesRequest) Descriptor() ([]byte, []int) {
|
||||
return file_serve_segments_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetMinutesRequest) GetTimezone() string {
|
||||
if x != nil {
|
||||
return x.Timezone
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetSecondsRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Timezone string `protobuf:"bytes,1,opt,name=timezone,proto3" json:"timezone,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetSecondsRequest) Reset() {
|
||||
*x = GetSecondsRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_segments_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetSecondsRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetSecondsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetSecondsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_segments_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetSecondsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetSecondsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_serve_segments_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *GetSecondsRequest) GetTimezone() string {
|
||||
if x != nil {
|
||||
return x.Timezone
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetMillisecondsRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Timezone string `protobuf:"bytes,1,opt,name=timezone,proto3" json:"timezone,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetMillisecondsRequest) Reset() {
|
||||
*x = GetMillisecondsRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_segments_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetMillisecondsRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMillisecondsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetMillisecondsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_segments_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMillisecondsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetMillisecondsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_serve_segments_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *GetMillisecondsRequest) GetTimezone() string {
|
||||
if x != nil {
|
||||
return x.Timezone
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetHoursResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Hours uint32 `protobuf:"varint,1,opt,name=hours,proto3" json:"hours,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetHoursResponse) Reset() {
|
||||
*x = GetHoursResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_segments_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetHoursResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetHoursResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetHoursResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_segments_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetHoursResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetHoursResponse) Descriptor() ([]byte, []int) {
|
||||
return file_serve_segments_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *GetHoursResponse) GetHours() uint32 {
|
||||
if x != nil {
|
||||
return x.Hours
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type GetMinutesResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Minutes uint32 `protobuf:"varint,1,opt,name=minutes,proto3" json:"minutes,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetMinutesResponse) Reset() {
|
||||
*x = GetMinutesResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_segments_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetMinutesResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMinutesResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetMinutesResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_segments_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMinutesResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetMinutesResponse) Descriptor() ([]byte, []int) {
|
||||
return file_serve_segments_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *GetMinutesResponse) GetMinutes() uint32 {
|
||||
if x != nil {
|
||||
return x.Minutes
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type GetSecondsResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Seconds uint32 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetSecondsResponse) Reset() {
|
||||
*x = GetSecondsResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_segments_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetSecondsResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetSecondsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetSecondsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_segments_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetSecondsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetSecondsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_serve_segments_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *GetSecondsResponse) GetSeconds() uint32 {
|
||||
if x != nil {
|
||||
return x.Seconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type GetMillisecondsResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Milliseconds uint32 `protobuf:"varint,1,opt,name=milliseconds,proto3" json:"milliseconds,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetMillisecondsResponse) Reset() {
|
||||
*x = GetMillisecondsResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_serve_segments_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetMillisecondsResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMillisecondsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetMillisecondsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_serve_segments_proto_msgTypes[7]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMillisecondsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetMillisecondsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_serve_segments_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *GetMillisecondsResponse) GetMilliseconds() uint32 {
|
||||
if x != nil {
|
||||
return x.Milliseconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_serve_segments_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_serve_segments_proto_rawDesc = []byte{
|
||||
0x0a, 0x14, 0x73, 0x65, 0x72, 0x76, 0x65, 0x5f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2d, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x48, 0x6f, 0x75,
|
||||
0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x22, 0x2f, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x75,
|
||||
0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x22, 0x2f, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x65, 0x63,
|
||||
0x6f, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x74,
|
||||
0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74,
|
||||
0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x22, 0x34, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4d, 0x69,
|
||||
0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x22, 0x28, 0x0a,
|
||||
0x10, 0x47, 0x65, 0x74, 0x48, 0x6f, 0x75, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x12, 0x14, 0x0a, 0x05, 0x68, 0x6f, 0x75, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d,
|
||||
0x52, 0x05, 0x68, 0x6f, 0x75, 0x72, 0x73, 0x22, 0x2e, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x4d, 0x69,
|
||||
0x6e, 0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x6d, 0x69, 0x6e, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07,
|
||||
0x6d, 0x69, 0x6e, 0x75, 0x74, 0x65, 0x73, 0x22, 0x2e, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x53, 0x65,
|
||||
0x63, 0x6f, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07,
|
||||
0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x22, 0x3d, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x4d, 0x69,
|
||||
0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e,
|
||||
0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73,
|
||||
0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x32, 0xf4, 0x01, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x65,
|
||||
0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x48,
|
||||
0x6f, 0x75, 0x72, 0x73, 0x12, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x48, 0x6f, 0x75, 0x72, 0x73, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x47, 0x65, 0x74, 0x48, 0x6f, 0x75, 0x72,
|
||||
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x0a, 0x47, 0x65, 0x74,
|
||||
0x4d, 0x69, 0x6e, 0x75, 0x74, 0x65, 0x73, 0x12, 0x12, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x6e,
|
||||
0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x47, 0x65,
|
||||
0x74, 0x4d, 0x69, 0x6e, 0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x12, 0x35, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x12,
|
||||
0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x13, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4d, 0x69,
|
||||
0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x17, 0x2e, 0x47, 0x65, 0x74,
|
||||
0x4d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x65,
|
||||
0x63, 0x6f, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2b, 0x5a,
|
||||
0x29, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76,
|
||||
0x65, 0x5f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_serve_segments_proto_rawDescOnce sync.Once
|
||||
file_serve_segments_proto_rawDescData = file_serve_segments_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_serve_segments_proto_rawDescGZIP() []byte {
|
||||
file_serve_segments_proto_rawDescOnce.Do(func() {
|
||||
file_serve_segments_proto_rawDescData = protoimpl.X.CompressGZIP(file_serve_segments_proto_rawDescData)
|
||||
})
|
||||
return file_serve_segments_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_serve_segments_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_serve_segments_proto_goTypes = []interface{}{
|
||||
(*GetHoursRequest)(nil), // 0: GetHoursRequest
|
||||
(*GetMinutesRequest)(nil), // 1: GetMinutesRequest
|
||||
(*GetSecondsRequest)(nil), // 2: GetSecondsRequest
|
||||
(*GetMillisecondsRequest)(nil), // 3: GetMillisecondsRequest
|
||||
(*GetHoursResponse)(nil), // 4: GetHoursResponse
|
||||
(*GetMinutesResponse)(nil), // 5: GetMinutesResponse
|
||||
(*GetSecondsResponse)(nil), // 6: GetSecondsResponse
|
||||
(*GetMillisecondsResponse)(nil), // 7: GetMillisecondsResponse
|
||||
}
|
||||
var file_serve_segments_proto_depIdxs = []int32{
|
||||
0, // 0: ServeSegments.GetHours:input_type -> GetHoursRequest
|
||||
1, // 1: ServeSegments.GetMinutes:input_type -> GetMinutesRequest
|
||||
2, // 2: ServeSegments.GetSeconds:input_type -> GetSecondsRequest
|
||||
3, // 3: ServeSegments.GetMilliseconds:input_type -> GetMillisecondsRequest
|
||||
4, // 4: ServeSegments.GetHours:output_type -> GetHoursResponse
|
||||
5, // 5: ServeSegments.GetMinutes:output_type -> GetMinutesResponse
|
||||
6, // 6: ServeSegments.GetSeconds:output_type -> GetSecondsResponse
|
||||
7, // 7: ServeSegments.GetMilliseconds:output_type -> GetMillisecondsResponse
|
||||
4, // [4:8] is the sub-list for method output_type
|
||||
0, // [0:4] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_serve_segments_proto_init() }
|
||||
func file_serve_segments_proto_init() {
|
||||
if File_serve_segments_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_serve_segments_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetHoursRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_serve_segments_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetMinutesRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_serve_segments_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetSecondsRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_serve_segments_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetMillisecondsRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_serve_segments_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetHoursResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_serve_segments_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetMinutesResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_serve_segments_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetSecondsResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_serve_segments_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetMillisecondsResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_serve_segments_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_serve_segments_proto_goTypes,
|
||||
DependencyIndexes: file_serve_segments_proto_depIdxs,
|
||||
MessageInfos: file_serve_segments_proto_msgTypes,
|
||||
}.Build()
|
||||
File_serve_segments_proto = out.File
|
||||
file_serve_segments_proto_rawDesc = nil
|
||||
file_serve_segments_proto_goTypes = nil
|
||||
file_serve_segments_proto_depIdxs = nil
|
||||
}
|
||||
@ -0,0 +1,213 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.21.12
|
||||
// source: serve_segments.proto
|
||||
|
||||
package serve_segments
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// ServeSegmentsClient is the client API for ServeSegments service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type ServeSegmentsClient interface {
|
||||
GetHours(ctx context.Context, in *GetHoursRequest, opts ...grpc.CallOption) (*GetHoursResponse, error)
|
||||
GetMinutes(ctx context.Context, in *GetMinutesRequest, opts ...grpc.CallOption) (*GetMinutesResponse, error)
|
||||
GetSeconds(ctx context.Context, in *GetSecondsRequest, opts ...grpc.CallOption) (*GetSecondsResponse, error)
|
||||
GetMilliseconds(ctx context.Context, in *GetMillisecondsRequest, opts ...grpc.CallOption) (*GetMillisecondsResponse, error)
|
||||
}
|
||||
|
||||
type serveSegmentsClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewServeSegmentsClient(cc grpc.ClientConnInterface) ServeSegmentsClient {
|
||||
return &serveSegmentsClient{cc}
|
||||
}
|
||||
|
||||
func (c *serveSegmentsClient) GetHours(ctx context.Context, in *GetHoursRequest, opts ...grpc.CallOption) (*GetHoursResponse, error) {
|
||||
out := new(GetHoursResponse)
|
||||
err := c.cc.Invoke(ctx, "/ServeSegments/GetHours", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *serveSegmentsClient) GetMinutes(ctx context.Context, in *GetMinutesRequest, opts ...grpc.CallOption) (*GetMinutesResponse, error) {
|
||||
out := new(GetMinutesResponse)
|
||||
err := c.cc.Invoke(ctx, "/ServeSegments/GetMinutes", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *serveSegmentsClient) GetSeconds(ctx context.Context, in *GetSecondsRequest, opts ...grpc.CallOption) (*GetSecondsResponse, error) {
|
||||
out := new(GetSecondsResponse)
|
||||
err := c.cc.Invoke(ctx, "/ServeSegments/GetSeconds", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *serveSegmentsClient) GetMilliseconds(ctx context.Context, in *GetMillisecondsRequest, opts ...grpc.CallOption) (*GetMillisecondsResponse, error) {
|
||||
out := new(GetMillisecondsResponse)
|
||||
err := c.cc.Invoke(ctx, "/ServeSegments/GetMilliseconds", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ServeSegmentsServer is the server API for ServeSegments service.
|
||||
// All implementations must embed UnimplementedServeSegmentsServer
|
||||
// for forward compatibility
|
||||
type ServeSegmentsServer interface {
|
||||
GetHours(context.Context, *GetHoursRequest) (*GetHoursResponse, error)
|
||||
GetMinutes(context.Context, *GetMinutesRequest) (*GetMinutesResponse, error)
|
||||
GetSeconds(context.Context, *GetSecondsRequest) (*GetSecondsResponse, error)
|
||||
GetMilliseconds(context.Context, *GetMillisecondsRequest) (*GetMillisecondsResponse, error)
|
||||
mustEmbedUnimplementedServeSegmentsServer()
|
||||
}
|
||||
|
||||
// UnimplementedServeSegmentsServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedServeSegmentsServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedServeSegmentsServer) GetHours(context.Context, *GetHoursRequest) (*GetHoursResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetHours not implemented")
|
||||
}
|
||||
func (UnimplementedServeSegmentsServer) GetMinutes(context.Context, *GetMinutesRequest) (*GetMinutesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetMinutes not implemented")
|
||||
}
|
||||
func (UnimplementedServeSegmentsServer) GetSeconds(context.Context, *GetSecondsRequest) (*GetSecondsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSeconds not implemented")
|
||||
}
|
||||
func (UnimplementedServeSegmentsServer) GetMilliseconds(context.Context, *GetMillisecondsRequest) (*GetMillisecondsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetMilliseconds not implemented")
|
||||
}
|
||||
func (UnimplementedServeSegmentsServer) mustEmbedUnimplementedServeSegmentsServer() {}
|
||||
|
||||
// UnsafeServeSegmentsServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ServeSegmentsServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeServeSegmentsServer interface {
|
||||
mustEmbedUnimplementedServeSegmentsServer()
|
||||
}
|
||||
|
||||
func RegisterServeSegmentsServer(s grpc.ServiceRegistrar, srv ServeSegmentsServer) {
|
||||
s.RegisterService(&ServeSegments_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _ServeSegments_GetHours_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetHoursRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ServeSegmentsServer).GetHours(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ServeSegments/GetHours",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ServeSegmentsServer).GetHours(ctx, req.(*GetHoursRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ServeSegments_GetMinutes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetMinutesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ServeSegmentsServer).GetMinutes(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ServeSegments/GetMinutes",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ServeSegmentsServer).GetMinutes(ctx, req.(*GetMinutesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ServeSegments_GetSeconds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetSecondsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ServeSegmentsServer).GetSeconds(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ServeSegments/GetSeconds",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ServeSegmentsServer).GetSeconds(ctx, req.(*GetSecondsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ServeSegments_GetMilliseconds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetMillisecondsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ServeSegmentsServer).GetMilliseconds(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ServeSegments/GetMilliseconds",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ServeSegmentsServer).GetMilliseconds(ctx, req.(*GetMillisecondsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// ServeSegments_ServiceDesc is the grpc.ServiceDesc for ServeSegments service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var ServeSegments_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "ServeSegments",
|
||||
HandlerType: (*ServeSegmentsServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetHours",
|
||||
Handler: _ServeSegments_GetHours_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetMinutes",
|
||||
Handler: _ServeSegments_GetMinutes_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetSeconds",
|
||||
Handler: _ServeSegments_GetSeconds_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetMilliseconds",
|
||||
Handler: _ServeSegments_GetMilliseconds_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "serve_segments.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user