Beispiel #1
0
 def _parse_type_desc(type_desc, names):
     type_schema = schema.schema_from_json_data(type_desc, names=names)
     if type_schema.type not in VALID_TYPE_SCHEMA_TYPES:
         raise ProtocolParseException(
             'Invalid type %r in protocol %r: '
             'protocols can only declare types %s.' %
             (type_schema, avro_name, ','.join(VALID_TYPE_SCHEMA_TYPES)))
     return type_schema
Beispiel #2
0
 def _parse_type_desc(type_desc, names):
     type_schema = schema.schema_from_json_data(type_desc, names=names)
     if type_schema.type not in VALID_TYPE_SCHEMA_TYPES:
         raise ProtocolParseException(
             'Invalid type %r in protocol %r: '
             'protocols can only declare types %s.'
             % (type_schema, avro_name, ','.join(VALID_TYPE_SCHEMA_TYPES)))
     return type_schema
Beispiel #3
0
    def _parse_response_from_json_desc(response_desc, names):
        """Parses the response descriptor of a protocol message.

        Args:
            response_desc: Descriptor of the message response.
                This is an arbitrary Avro schema descriptor.
        Returns:
            The parsed response schema.
        """
        return schema.schema_from_json_data(response_desc, names=names)
Beispiel #4
0
    def _parse_response_from_json_desc(response_desc, names):
        """Parses the response descriptor of a protocol message.

        Args:
            response_desc: Descriptor of the message response.
                This is an arbitrary Avro schema descriptor.
        Returns:
            The parsed response schema.
        """
        return schema.schema_from_json_data(response_desc, names=names)
Beispiel #5
0
    def _parse_errors_from_json_desc(errors_desc, names):
        """Parses the errors descriptor of a protocol message.

        Args:
            errors_desc: Descriptor of the errors thrown by the protocol message.
                This is a list of error types understood as an implicit union.
                Each error type is an arbitrary Avro schema.
            names: Tracker for named Avro schemas.
        Returns:
            The parsed ErrorUnionSchema.
        """
        error_union_desc = {
            'type': schema.ERROR_UNION,
            'declared_errors': errors_desc,
        }
        return schema.schema_from_json_data(error_union_desc, names=names)
Beispiel #6
0
    def _parse_errors_from_json_desc(errors_desc, names):
        """Parses the errors descriptor of a protocol message.

        Args:
            errors_desc: Descriptor of the errors thrown by the protocol message.
                This is a list of error types understood as an implicit union.
                Each error type is an arbitrary Avro schema.
            names: Tracker for named Avro schemas.
        Returns:
            The parsed ErrorUnionSchema.
        """
        error_union_desc = {
            'type': schema.ERROR_UNION,
            'declared_errors': errors_desc,
        }
        return schema.schema_from_json_data(error_union_desc, names=names)