Add structured events

This commit is contained in:
oldnapalm
2025-06-16 18:46:59 -03:00
parent 832dadc39d
commit c78b4232cf
5 changed files with 50 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ all:
protoc --python_out=. user_storage.proto
protoc --python_out=. fitness.proto
protoc --python_out=. race-result.proto
protoc --python_out=. structured_events.proto
clean:
rm -f *_pb2.py *_pb2.pyc

View File

@@ -17,5 +17,6 @@ protoc --python_out=. route-result.proto
protoc --python_out=. user_storage.proto
protoc --python_out=. fitness.proto
protoc --python_out=. race-result.proto
protoc --python_out=. structured_events.proto
pause

View File

@@ -0,0 +1,9 @@
syntax = "proto2";
message SaveStructuredEventRequest {
optional uint32 sequenceNumber = 1;
}
message SaveStructuredEventResponse {
optional uint32 sequenceNumber = 1;
}

View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: structured_events.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\x17structured_events.proto\"4\n\x1aSaveStructuredEventRequest\x12\x16\n\x0esequenceNumber\x18\x01 \x01(\r\"5\n\x1bSaveStructuredEventResponse\x12\x16\n\x0esequenceNumber\x18\x01 \x01(\r')
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'structured_events_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:
DESCRIPTOR._options = None
_SAVESTRUCTUREDEVENTREQUEST._serialized_start=27
_SAVESTRUCTUREDEVENTREQUEST._serialized_end=79
_SAVESTRUCTUREDEVENTRESPONSE._serialized_start=81
_SAVESTRUCTUREDEVENTRESPONSE._serialized_end=134
# @@protoc_insertion_point(module_scope)

View File

@@ -58,8 +58,10 @@ import events_pb2
import variants_pb2
import playback_pb2
import user_storage_pb2
import online_sync
import fitness_pb2
import structured_events_pb2
import online_sync
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
logger = logging.getLogger('zoffline')
@@ -1738,7 +1740,15 @@ def hvc_ingestion_service_batch():
@app.route('/api/actions-service/structured-events/batch', methods=['POST'])
def api_actions_service_structured_events_batch():
return '', 202
stream = request.stream.read()
#import blackboxprotobuf
#message, typedef = blackboxprotobuf.protobuf_to_json(stream)
#print(json.dumps(json.loads(message), indent=2))
req = structured_events_pb2.SaveStructuredEventRequest()
req.ParseFromString(stream)
res = structured_events_pb2.SaveStructuredEventResponse()
res.sequenceNumber = req.sequenceNumber
return res.SerializeToString(), 202
def age(dob):