Adding type info to Converter interface.
Signed-off-by: Evan Anderson <argent@google.com>
This commit is contained in:
parent
d90a4861f9
commit
47873fbca1
|
@ -25,10 +25,10 @@ class Converter(object):
|
||||||
data_unmarshaller: typing.Callable) -> base.BaseEvent:
|
data_unmarshaller: typing.Callable) -> base.BaseEvent:
|
||||||
raise Exception("not implemented")
|
raise Exception("not implemented")
|
||||||
|
|
||||||
def event_supported(self, event):
|
def event_supported(self, event: object) -> bool:
|
||||||
raise Exception("not implemented")
|
raise Exception("not implemented")
|
||||||
|
|
||||||
def can_read(self, content_type):
|
def can_read(self, content_type: str) -> bool:
|
||||||
raise Exception("not implemented")
|
raise Exception("not implemented")
|
||||||
|
|
||||||
def write(self, event: base.BaseEvent,
|
def write(self, event: base.BaseEvent,
|
||||||
|
|
|
@ -25,10 +25,10 @@ class BinaryHTTPCloudEventConverter(base.Converter):
|
||||||
TYPE = "binary"
|
TYPE = "binary"
|
||||||
SUPPORTED_VERSIONS = [v02.Event, ]
|
SUPPORTED_VERSIONS = [v02.Event, ]
|
||||||
|
|
||||||
def can_read(self, content_type):
|
def can_read(self, content_type: str) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def event_supported(self, event):
|
def event_supported(self, event: object) -> bool:
|
||||||
return type(event) in self.SUPPORTED_VERSIONS
|
return type(event) in self.SUPPORTED_VERSIONS
|
||||||
|
|
||||||
def read(self,
|
def read(self,
|
||||||
|
|
|
@ -23,10 +23,10 @@ class JSONHTTPCloudEventConverter(base.Converter):
|
||||||
TYPE = "structured"
|
TYPE = "structured"
|
||||||
MIME_TYPE = "application/cloudevents+json"
|
MIME_TYPE = "application/cloudevents+json"
|
||||||
|
|
||||||
def can_read(self, content_type):
|
def can_read(self, content_type: str) -> bool:
|
||||||
return content_type and content_type.startswith(self.MIME_TYPE)
|
return content_type and content_type.startswith(self.MIME_TYPE)
|
||||||
|
|
||||||
def event_supported(self, event):
|
def event_supported(self, event: object) -> bool:
|
||||||
# structured format supported by both spec 0.1 and 0.2
|
# structured format supported by both spec 0.1 and 0.2
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue