Hi, I am developing a custom connector (generic Py...
# help-connector-development
e
Hi, I am developing a custom connector (generic Python, extending SOURCE class ), I am also emitting a state like this:
yield AirbyteMessage(
type=Type.STATE,
state=AirbyteStateMessage(data={stream.name: {"date": max_date}})
)
it works well, but as I have multiple streams, I need to emit a state per each of them. For some reasons, it looks like just the latest gets saved.
k
A message from kapa.ai
New message text here
j
data
is the legacy global state, that's why only the latest one sticks
Check out the
stream
parameter of AirbyteStateMessage
e
Hey, do you have any example?
I am struggling to find the definition of AirbyteStateMessage in Python
j
It's a regular python class
In most cases however you don't have to deal with this level, instead you can implement the
Stream
class. Check out the existing sources in https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors
e
ok, so it is suggested to use AbstractSource instead of Source? I find Souce easier to understand
j
it's a lower level of the abstraction, that's why you have to deal with writing the state yourself
e
I don't mind that to be honest. I'll try
it works fine like this:
yield AirbyteMessage(
type=Type.STATE,
state=AirbyteStateMessage(type="STREAM", stream=AirbyteStreamState(stream_descriptor=StreamDescriptor(name=stream.name), stream_state=AirbyteStateBlob(date=max_date)))
)
needed to experiment a lot. You guys have a great bot, but for custom connector, the documentation is too much about http
v
custom connector documentation is a wild west