コード例 #1
0
class Packet(Message):
    magic_number = Int32Field(field_number=1,
                              default=17,
                              oneof_id='magic_number_present')
    version = Int32Field(field_number=2, default=1, oneof_id='version_present')
    type = EnumField(field_number=3, enum_cls=PacketType)
    compression = EnumField(field_number=4,
                            enum_cls=Compression,
                            default=Compression.NONE,
                            oneof_id='compression_present')
    body = BytesField(field_number=5)
コード例 #2
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)
コード例 #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 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)
コード例 #5
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
        }
コード例 #6
0
ファイル: consumer.py プロジェクト: harishbisht/kafka-docker
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)
コード例 #7
0
ファイル: protocol.py プロジェクト: bshishov/LudumDare40
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))
EntityState.add_field('damage_mod', Int32Field(field_number=11, optional=True))
コード例 #8
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))
コード例 #9
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))
コード例 #10
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)
コード例 #11
0
class Task(Message):
    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(
コード例 #12
0
ファイル: network_pb3.py プロジェクト: adis300/ffnn-c
class Weight(Message):
    pass


class Bias(Message):
    pass


class Network(Message):
    class ActivationType(Enum):
        SIGMOID = 0
        LINEAR = 1
        RELU = 2
        THRESHOLD = 3
        SOFTMAX = 4


Weight.add_field('col', Int32Field(field_number=1, optional=True))
Weight.add_field('row', Int32Field(field_number=2, optional=True))
Weight.add_field('grid', DoubleField(field_number=3, repeated=True))
Bias.add_field('vector', DoubleField(field_number=1, repeated=True))
Network.add_field('layerSizes', Int32Field(field_number=1, repeated=True))
Network.add_field(
    'activations',
    EnumField(field_number=2, repeated=True, enum_cls=Network.ActivationType))
Network.add_field(
    'weights', MessageField(field_number=3, repeated=True, message_cls=Weight))
Network.add_field(
    'biases', MessageField(field_number=4, repeated=True, message_cls=Bias))
コード例 #13
0

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))
ControlPointFileEntryV0002.PointLogData.add_field(
    'doubleDataValue', DoubleField(field_number=2, optional=True))
ControlPointFileEntryV0002.PointLogData.add_field(
    'boolDataType', Int32Field(field_number=3, optional=True))
ControlPointFileEntryV0002.PointLogData.add_field(
    'boolDataValue', BoolField(field_number=4, optional=True))
ControlPointFileEntryV0002.Measure.MeasureLogData.add_field(
    'doubleDataType', Int32Field(field_number=1, optional=True))
ControlPointFileEntryV0002.Measure.MeasureLogData.add_field(
    'doubleDataValue', DoubleField(field_number=2, optional=True))
ControlPointFileEntryV0002.Measure.MeasureLogData.add_field(
    'boolDataType', Int32Field(field_number=3, optional=True))