class Pair(Message): """预留扩展""" key = StringField(field_number=1) value = StringField(field_number=2) def to_json(self): return {'key': self.key, 'value': self.value}
class Header(Message): # 协议的版本号 version = Int32Field(field_number=1, default=1, oneof_id='version_present') # binlog/redolog 文件名 logfileName = StringField(field_number=2) # binlog/redolog 文件的偏移位置 logfileOffset = Int64Field(field_number=3) # 服务端serverId serverId = Int64Field(field_number=4) # 变更数据的编码 serverenCode = StringField(field_number=5) # 变更数据的执行时间 executeTime = Int64Field(field_number=6) # 变更数据的来源 sourceType = EnumField(field_number=7, default=Type.MYSQL, enum_cls=Type, oneof_id='sourceType_present') # 变更数据的schemaname schemaName = StringField(field_number=8) # 变更数据的tablename tableName = StringField(field_number=9) # 每个event的长度 eventLength = Int64Field(field_number=10) # 数据变更类型 eventType = EnumField(field_number=11, default=EventType.UPDATE, enum_cls=EventType, oneof_id='eventType_present') # 预留扩展 props = MessageField(field_number=12, repeated=True, message_cls=Pair) # 当前事务的gitd gtid = StringField(field_number=13)
class Get(Message): """PullRequest""" destination = StringField(field_number=1) client_id = StringField(field_number=2) fetch_size = Int32Field(field_number=3) # 默认-1时代表不控制 timeout = Int64Field(field_number=4, default=-1, oneof_id='timeout_present') # 数字类型,0:纳秒,1:毫秒,2:微秒,3:秒,4:分钟,5:小时,6:天 unit = Int32Field(field_number=5, default=2, oneof_id='unit_present') # 是否自动ack auto_ack = BoolField(field_number=6, default=False, oneof_id='auto_ack_present')
class ClientAuth(Message): username = StringField(field_number=1) password = BytesField(field_number=2) # in seconds net_read_timeout = Int32Field(field_number=3, default=0, oneof_id='net_read_timeout_present') # in seconds net_write_timeout = Int32Field(field_number=4, default=0, oneof_id='net_write_timeout_present') destination = StringField(field_number=5) client_id = StringField(field_number=6) filter = StringField(field_number=7) start_timestamp = Int64Field(field_number=8)
class Handshake(Message): communication_encoding = StringField( field_number=1, default='utf8', oneof_id='communication_encoding_present') seeds = BytesField(field_number=2) supported_compressions = EnumField(field_number=3, enum_cls=Compression)
class Dump(Message): """TBD when new packets are required""" journal = StringField(field_number=1) position = Int64Field(field_number=2) timestamp = Int64Field(field_number=3, default=0, oneof_id='timestamp_present')
class TransactionEnd(Message): """结束事务的一些信息""" # 已废弃,请使用header里的executeTime executeTime = Int64Field(field_number=1) # 事务号 transactionId = StringField(field_number=2) # 预留扩展 props = MessageField(field_number=3, repeated=True, message_cls=Pair)
class TransactionBegin(Message): """开始事务的一些信息""" # 已废弃,请使用header里的executeTime executeTime = Int64Field(field_number=1) # 已废弃,Begin里不提供事务id transactionId = StringField(field_number=2) # 预留扩展 props = MessageField(field_number=3, repeated=True, message_cls=Pair) # 执行的thread Id threadId = Int64Field(field_number=4)
class RowChange(Message): """message row 每行变更数据的数据结构""" # tableId,由数据库产生 tableId = Int64Field(field_number=1) # 数据变更类型 eventType = EnumField(field_number=2, default=EventType.UPDATE, enum_cls=EventType, oneof_id='eventType_present') # 标识是否是ddl语句 isDdl = BoolField(field_number=10, default=False, oneof_id='isDdl_present') # ddl/query的sql语句 sql = StringField(field_number=11) # 一次数据库变更可能存在多行 rowDatas = MessageField(field_number=12, repeated=True, message_cls=RowData) # 预留扩展 props = MessageField(field_number=13, repeated=True, message_cls=Pair) # ddl/query的schemaName,会存在跨库ddl,需要保留执行ddl的当前schemaName ddlSchemaName = StringField(field_number=14, optional=True)
class Column(Message): """每个字段的数据结构""" # 字段下标 index = Int32Field(field_number=1) # 字段java中类型 sqlType = Int32Field(field_number=2) # 字段名称(忽略大小写),在mysql中是没有的 name = StringField(field_number=3) # 是否是主键 isKey = BoolField(field_number=4) # 如果EventType=UPDATE,用于标识这个字段值是否有修改 updated = BoolField(field_number=5) # 标识是否为空 isNull = BoolField(field_number=6, default=False) # 预留扩展 props = MessageField(field_number=7, repeated=True, message_cls=Pair) # 字段值,timestamp,Datetime是一个时间格式的文本 value = StringField(field_number=8) # 对应数据对象原始长度 length = Int32Field(field_number=9) # 字段mysql类型 mysqlType = StringField(field_number=10) def to_json(self): return { 'index': self.index, 'sqlType': self.sqlType, 'name': self.name, 'isKey': self.isKey, 'updated': self.updated, 'isNull': self.isNull, 'props': [p.to_json() for p in self.props], 'value': self.value, 'length': self.length, 'mysqlType': self.mysqlType }
class Side(Enum): NEUTRAL = 0 A = 1 B = 2 class PlayerAction(Enum): PLAY_CARD = 0 FIRE_WEAPON = 1 END_TURN = 2 CHEAT_GAIN_CARD = 3 BuffState.add_field('name', StringField(field_number=1, optional=True)) BuffState.add_field('duration', Int32Field(field_number=2, optional=True)) CardState.add_field('name', StringField(field_number=1, optional=True)) CardState.add_field('cost_offense', Int32Field(field_number=2, optional=True)) CardState.add_field('cost_defense', Int32Field(field_number=3, optional=True)) EntityState.add_field('id', Int32Field(field_number=1, optional=True)) EntityState.add_field('name', StringField(field_number=2, optional=True)) EntityState.add_field('side', EnumField(field_number=3, optional=True, enum_cls=Side)) EntityState.add_field('hp', Int32Field(field_number=4, optional=True)) EntityState.add_field('energy', Int32Field(field_number=5, optional=True)) EntityState.add_field('max_energy', Int32Field(field_number=6, optional=True)) EntityState.add_field('energy_gain', Int32Field(field_number=7, optional=True)) EntityState.add_field('muted', BoolField(field_number=8, optional=True)) EntityState.add_field('armed', BoolField(field_number=9, optional=True)) EntityState.add_field('locked', BoolField(field_number=10, optional=True))
from protobuf3.message import Message from protobuf3.fields import MessageField, Int32Field, StringField class BaseReply(Message): class SpareParameterEntry(Message): pass BaseReply.SpareParameterEntry.add_field( 'key', StringField(field_number=1, optional=True)) BaseReply.SpareParameterEntry.add_field( 'value', StringField(field_number=2, optional=True)) BaseReply.add_field('Code', Int32Field(field_number=1, optional=True)) BaseReply.add_field('Message', StringField(field_number=2, optional=True)) BaseReply.add_field( 'spareParameter', MessageField(field_number=3, repeated=True, message_cls=BaseReply.SpareParameterEntry))
from protobuf3.message import Message from protobuf3.fields import Int32Field, StringField, Int64Field, BytesField class MintPayload(Message): pass class MQMessage(Message): pass MintPayload.add_field('partition', Int32Field(field_number=1, optional=True)) MintPayload.add_field('number', StringField(field_number=2, optional=True)) MintPayload.add_field('time', Int64Field(field_number=3, optional=True)) MQMessage.add_field('caller', StringField(field_number=1, optional=True)) MQMessage.add_field('matrix', StringField(field_number=2, optional=True)) MQMessage.add_field('device', StringField(field_number=3, optional=True)) MQMessage.add_field('resource', StringField(field_number=4, optional=True)) MQMessage.add_field('action', StringField(field_number=5, optional=True)) MQMessage.add_field('payload', BytesField(field_number=6, optional=True)) MQMessage.add_field('time', Int64Field(field_number=7, optional=True))
class ClientAck(Message): destination = StringField(field_number=1) client_id = StringField(field_number=2) batch_id = Int64Field(field_number=3)
class Sub(Message): """subscription""" destination = StringField(field_number=1) client_id = StringField(field_number=2) filter = StringField(field_number=7)
class PointLogData(Message): pass class Measure(Message): class MeasureType(Enum): Candidate = 0 Manual = 1 RegisteredPixel = 2 RegisteredSubPixel = 3 class MeasureLogData(Message): pass ControlNetFileHeaderV0002.add_field('networkId', StringField(field_number=1, required=True)) ControlNetFileHeaderV0002.add_field('targetName', StringField(field_number=2, required=True)) ControlNetFileHeaderV0002.add_field('created', StringField(field_number=3, optional=True)) ControlNetFileHeaderV0002.add_field('lastModified', StringField(field_number=4, optional=True)) ControlNetFileHeaderV0002.add_field('description', StringField(field_number=5, optional=True)) ControlNetFileHeaderV0002.add_field('userName', StringField(field_number=6, optional=True)) ControlNetFileHeaderV0002.add_field('pointMessageSizes', Int32Field(field_number=7, repeated=True)) ControlPointFileEntryV0002.PointLogData.add_field( 'doubleDataType', Int32Field(field_number=1, optional=True))
class Ack(Message): error_code = Int32Field(field_number=1, default=0, oneof_id='error_code_present') # if something like compression is not supported, erorr_message will tell about it. error_message = StringField(field_number=2)
from protobuf3.message import Message from protobuf3.fields import StringField class request_for_connect(Message): pass request_for_connect.add_field('ua', StringField(field_number=1, optional=True)) request_for_connect.add_field('pubkey', StringField(field_number=2, optional=True))
class RotationP(Message): pass class ColorImageP(Message): pass class DepthImageP(Message): pass class FeelingsP(Message): pass UserP.add_field('user_id', UInt64Field(field_number=1, optional=True)) UserP.add_field('username', StringField(field_number=2, optional=True)) UserP.add_field('birthday', UInt32Field(field_number=3, optional=True)) UserP.add_field( 'gender', EnumField(field_number=4, optional=True, enum_cls=UserP.Gender)) ConfigP.add_field('supported_fields', StringField(field_number=1, repeated=True)) SnapshotP.PoseP.TranslationP.add_field( 'x', DoubleField(field_number=1, optional=True)) SnapshotP.PoseP.TranslationP.add_field( 'y', DoubleField(field_number=2, optional=True)) SnapshotP.PoseP.TranslationP.add_field( 'z', DoubleField(field_number=3, optional=True)) SnapshotP.PoseP.RotationP.add_field('x', DoubleField(field_number=1, optional=True)) SnapshotP.PoseP.RotationP.add_field('y', DoubleField(field_number=2, optional=True))
class AnswerType(Enum): STRING = 0 INT = 1 DOUBLE = 2 class Answer(Message): pass class AddTask(Message): pass Task.Answer.add_field('data', Int32Field(field_number=1, required=True)) Task.Answer.add_field( 'type', EnumField(field_number=2, optional=True, enum_cls=Task.AnswerType, default=Task.AnswerType.INT)) Task.add_field('id', Int32Field(field_number=1, required=True)) Task.add_field('title', StringField(field_number=2, optional=True)) Task.add_field('content', StringField(field_number=3, optional=True)) Task.add_field('score', Int32Field(field_number=4, required=True)) Task.add_field('author', StringField(field_number=5, optional=True)) Task.add_field( 'answer', MessageField(field_number=6, repeated=True, message_cls=Task.Answer)) AddTask.add_field( 'task', MessageField(field_number=1, repeated=True, message_cls=Task))
class Iso(Message): class MapNode(Message): pass class MapEdge(Message): pass Iso.MapNode.add_field('id_1', UInt64Field(field_number=1, required=True)) Iso.MapNode.add_field('id_2', UInt64Field(field_number=2, required=True)) Iso.MapNode.add_field('weight', DoubleField(field_number=3, optional=True)) Iso.MapEdge.add_field('id_1', UInt64Field(field_number=1, required=True)) Iso.MapEdge.add_field('id_2', UInt64Field(field_number=2, required=True)) Iso.MapEdge.add_field('weight', DoubleField(field_number=3, optional=True)) Iso.add_field('graph_1_id', StringField(field_number=1, required=True)) Iso.add_field('graph_2_id', StringField(field_number=2, required=True)) Iso.add_field( 'map_node', MessageField(field_number=3, repeated=True, message_cls=Iso.MapNode)) Iso.add_field( 'map_edge', MessageField(field_number=4, repeated=True, message_cls=Iso.MapEdge)) Iso.add_field('weight', DoubleField(field_number=5, optional=True)) Iso.add_field('obj_value', DoubleField(field_number=6, optional=True)) Iso.add_field('dataNodeMatchCount', UInt64Field(field_number=7, optional=True)) Iso.add_field('dataEdgeMatchCount', UInt64Field(field_number=8, optional=True)) Iso.add_field('controlEdgeMatchCount', UInt64Field(field_number=9, optional=True)) Iso.add_field('methodNodeMatchCount', UInt64Field(field_number=10, optional=True))
class Transaction(Message): transaction_id = StringField(field_number=1, required=True) account_number = Int32Field(field_number=2, required=True) transaction_reference = StringField(field_number=3, required=True) transaction_datetime = StringField(field_number=4, required=True) amount = Int32Field(field_number=5, required=True)
from protobuf3.message import Message from protobuf3.fields import StringField class request_for_add_pc_tail(Message): pass request_for_add_pc_tail.add_field('ua', StringField(field_number=1, optional=True)) request_for_add_pc_tail.add_field('encoded_pc_tail', StringField(field_number=2, optional=True))
class ColorImage(Message): pass class DepthImage(Message): pass class Feelings(Message): pass User.add_field('user_id', UInt64Field(field_number=1, optional=True)) User.add_field('username', StringField(field_number=2, optional=True)) User.add_field('birthday', UInt32Field(field_number=3, optional=True)) User.add_field('gender', EnumField(field_number=4, optional=True, enum_cls=User.Gender)) Snapshot.add_field('datetime', UInt64Field(field_number=1, optional=True)) Snapshot.add_field('pose', MessageField(field_number=2, optional=True, message_cls=Pose)) Snapshot.add_field('color_image', MessageField(field_number=3, optional=True, message_cls=ColorImage)) Snapshot.add_field('depth_image', MessageField(field_number=4, optional=True, message_cls=DepthImage)) Snapshot.add_field('feelings', MessageField(field_number=5, optional=True, message_cls=Feelings)) Pose.Translation.add_field('x', DoubleField(field_number=1, optional=True)) Pose.Translation.add_field('y', DoubleField(field_number=2, optional=True)) Pose.Translation.add_field('z', DoubleField(field_number=3, optional=True)) Pose.Rotation.add_field('x', DoubleField(field_number=1, optional=True)) Pose.Rotation.add_field('y', DoubleField(field_number=2, optional=True)) Pose.Rotation.add_field('z', DoubleField(field_number=3, optional=True)) Pose.Rotation.add_field('w', DoubleField(field_number=4, optional=True)) Pose.add_field('translation', MessageField(field_number=1, optional=True, message_cls=Pose.Translation))
class ExchangeAddress(Message): pass class ExchangeResponseV2(Message): pass class SignedExchangeResponse(Message): pass class ExchangeResponse(Message): pass ExchangeAddress.add_field('coin_type', StringField(field_number=1, optional=True)) ExchangeAddress.add_field('address', StringField(field_number=2, optional=True)) ExchangeAddress.add_field('dest_tag', StringField(field_number=3, optional=True)) ExchangeAddress.add_field('rs_address', StringField(field_number=4, optional=True)) ExchangeResponseV2.add_field('deposit_address', MessageField(field_number=1, optional=True, message_cls=ExchangeAddress)) ExchangeResponseV2.add_field('deposit_amount', BytesField(field_number=2, optional=True)) ExchangeResponseV2.add_field('expiration', Int64Field(field_number=3, optional=True)) ExchangeResponseV2.add_field('quoted_rate', BytesField(field_number=4, optional=True)) ExchangeResponseV2.add_field('withdrawal_address', MessageField(field_number=5, optional=True, message_cls=ExchangeAddress)) ExchangeResponseV2.add_field('withdrawal_amount', BytesField(field_number=6, optional=True)) ExchangeResponseV2.add_field('return_address', MessageField(field_number=7, optional=True, message_cls=ExchangeAddress)) ExchangeResponseV2.add_field('api_key', BytesField(field_number=8, optional=True)) ExchangeResponseV2.add_field('miner_fee', BytesField(field_number=9, optional=True)) ExchangeResponseV2.add_field('order_id', BytesField(field_number=10, optional=True)) SignedExchangeResponse.add_field('response', MessageField(field_number=1, optional=True, message_cls=ExchangeResponse)) SignedExchangeResponse.add_field('signature', BytesField(field_number=2, optional=True))
pass class LabelMap(Message): pass class RepoTag(Message): pass class MethodBag(Message): pass class SourceInfo(Message): pass Acdfg.DataNode.add_field('id', UInt64Field(field_number=1, required=True)) Acdfg.DataNode.add_field('name', StringField(field_number=2, required=True)) Acdfg.DataNode.add_field('type', StringField(field_number=3, required=True)) Acdfg.DataNode.add_field('data_type', EnumField(field_number=4, optional=True, enum_cls=Acdfg.DataNode.DataType)) Acdfg.MiscNode.add_field('id', UInt64Field(field_number=1, required=True)) Acdfg.MethodNode.add_field('id', UInt64Field(field_number=1, required=True)) Acdfg.MethodNode.add_field('assignee', UInt64Field(field_number=5, optional=True)) Acdfg.MethodNode.add_field('invokee', UInt64Field(field_number=2, optional=True)) Acdfg.MethodNode.add_field('name', StringField(field_number=3, required=True)) Acdfg.MethodNode.add_field('argument', UInt64Field(field_number=4, repeated=True)) Acdfg.ControlEdge.add_field('id', UInt64Field(field_number=1, required=True)) Acdfg.ControlEdge.add_field('from', UInt64Field(field_number=2, required=True)) Acdfg.ControlEdge.add_field('to', UInt64Field(field_number=3, required=True)) Acdfg.DefEdge.add_field('id', UInt64Field(field_number=1, required=True)) Acdfg.DefEdge.add_field('from', UInt64Field(field_number=2, required=True)) Acdfg.DefEdge.add_field('to', UInt64Field(field_number=3, required=True)) Acdfg.UseEdge.add_field('id', UInt64Field(field_number=1, required=True))