예제 #1
0
class Pair(Message):
    """预留扩展"""
    key = StringField(field_number=1)
    value = StringField(field_number=2)

    def to_json(self):
        return {'key': self.key, 'value': self.value}
예제 #2
0
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)
예제 #3
0
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')
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
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')
예제 #7
0
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)
예제 #8
0
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)
예제 #9
0
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)
예제 #10
0
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
        }
예제 #11
0

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))
예제 #12
0
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))
예제 #13
0
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))
예제 #14
0
class ClientAck(Message):
    destination = StringField(field_number=1)
    client_id = StringField(field_number=2)
    batch_id = Int64Field(field_number=3)
예제 #15
0
class Sub(Message):
    """subscription"""
    destination = StringField(field_number=1)
    client_id = StringField(field_number=2)
    filter = StringField(field_number=7)
예제 #16
0
    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))
예제 #17
0
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)
예제 #18
0
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))
예제 #19
0
        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))
예제 #20
0
    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))
예제 #21
0
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))
예제 #22
0
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)
예제 #23
0
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))
예제 #24
0

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))
예제 #25
0
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))
예제 #26
0
        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))