Compare commits

...

11 Commits

Author SHA1 Message Date
67b9db2ed0 Cleanups and optimizations 2023-03-24 11:39:36 +01:00
ee741cc924 WS server 2023-03-24 08:08:38 +01:00
83a54a8848 Readme 2023-03-23 15:24:06 +01:00
6103ad47a5 Remove obsolete protos 2023-03-23 00:23:32 +01:00
8d1e31ac5f Prettify output 2023-03-23 00:21:20 +01:00
544b7d6c85 Prettify output 2023-03-23 00:19:16 +01:00
e247bdc929 Async python client 2023-03-23 00:09:07 +01:00
1542bd98c2 Unified ServeSegments 2023-03-22 23:09:54 +01:00
1d26d6625e Readme 2023-03-21 23:09:48 +01:00
3776bdca24 Serve seconds 2023-03-20 23:25:53 +01:00
1876158d9d Node example 2023-03-20 22:00:13 +01:00
36 changed files with 2020 additions and 555 deletions

View File

@ -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,6 +100,16 @@ 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`
@ -119,3 +126,21 @@ Tonic is a gRPC over HTTP/2 implementation focused on high performance, interope
[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
View 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>

View File

@ -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

View File

@ -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)
@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)
async def get_hours(stub: ServeSegmentsStub) -> int:
response: GetHoursResponse = await stub.GetHours(GetHoursRequest(timezone=TIMEZONE))
return response.hours
def run():
hours = get_hours()
print(">>>>>>>>>>>>> Hours:", 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
View 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

View File

@ -1,2 +1,4 @@
pydantic
grpcio
grpcio-tools
websockets

View 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)

View 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: ...

View File

@ -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)

View File

@ -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)

View File

@ -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: ...

View 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)

View 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: ...

View 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
View 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())

View File

@ -1,7 +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);
}

View File

@ -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; }

View File

@ -1,9 +0,0 @@
syntax = "proto3";
service ServeMilliseconds {
rpc GetMilliseconds(GetMillisecondsRequest) returns (GetMillisecondsResponse);
}
message GetMillisecondsRequest { string timezone = 1; }
message GetMillisecondsResponse { uint32 milliseconds = 1; }

View File

@ -1,9 +0,0 @@
syntax = "proto3";
service ServeMinutes {
rpc GetMinutes(GetMinutesRequest) returns (GetMinutesResponse);
}
message GetMinutesRequest { string timezone = 1; }
message GetMinutesResponse { uint32 minutes = 1; }

View File

@ -1,9 +0,0 @@
syntax = "proto3";
service ServeSeconds {
rpc GetSeconds(GetSecondsRequest) returns (GetSecondsResponse);
}
message GetSecondsRequest { string timezone = 1; }
message GetSecondsResponse { uint32 seconds = 1; }

View 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; }

View File

@ -1,27 +1,52 @@
const messages = require("./stubs/serve_currenttime_pb");
const services = require("./stubs/serve_currenttime_grpc_pb");
const grpc = require("@grpc/grpc-js");
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) {
var response = new messages.GetCurrentTimeResponse();
response.setMessage("Hello " + call.request.getName());
callback(null, response);
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() {
console.log(`Starting server on ${SERVE_CURRENTTIME_HOST}:${SERVE_CURRENTTIME_PORT}`);
var server = new grpc.Server();
server.addService(services.ServeCurrentTimeService, { getCurrentTime: getCurrentTime });
server.bindAsync(
`${SERVE_CURRENTTIME_HOST}:${SERVE_CURRENTTIME_PORT}`,
grpc.ServerCredentials.createInsecure(),
() => {
server.start();
}
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();

View File

@ -11,6 +11,8 @@
"@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",
@ -256,6 +258,16 @@
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ=="
},
"node_modules/dayjs": {
"version": "1.11.7",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz",
"integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ=="
},
"node_modules/dayjs-timezone-iana-plugin": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/dayjs-timezone-iana-plugin/-/dayjs-timezone-iana-plugin-0.1.0.tgz",
"integrity": "sha512-xc8cIZmi4oKr2nfu41I/FDWZKa8n8YaRMxSz9MrpXTNo8c6ZsjZuIoy5RPNmLXPqntFuITWI8obB7lUA+CdzGQ=="
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@ -1060,6 +1072,16 @@
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ=="
},
"dayjs": {
"version": "1.11.7",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz",
"integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ=="
},
"dayjs-timezone-iana-plugin": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/dayjs-timezone-iana-plugin/-/dayjs-timezone-iana-plugin-0.1.0.tgz",
"integrity": "sha512-xc8cIZmi4oKr2nfu41I/FDWZKa8n8YaRMxSz9MrpXTNo8c6ZsjZuIoy5RPNmLXPqntFuITWI8obB7lUA+CdzGQ=="
},
"debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",

View File

@ -1,10 +1,13 @@
{
"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",

View File

@ -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)

View File

@ -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()
}

View File

@ -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
}

View File

@ -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",
}

View 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

View File

@ -1,4 +1,4 @@
module serve_hours
module serve_segments
go 1.20

122
src/serve_segments/main.go Normal file
View 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()
}

View File

@ -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
}

View File

@ -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",
}

View 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
}

View File

@ -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",
}