Gateway and Connectors

Bytewax has many different data entry points or connectors. These can be gRPC endpoints, Kafka connectors, or RESTful endpoints. These are deployed on Bytewax and can be reached by other services. The Bytewax SDK contains methods that allow developers to easily connect data sources to Bytewax via requests, topics or other. The default standard is the Bytewax Gateway and this is what we have seen so far in the examples. In the examples we use the Gateway to communicate between the application service and our Bytewax Swarm.

Creating a Gateway Subject

The default way for a Swarm to receive data, ultimately triggering the Bees to execute, is to instruct the swarm to listen on a subject on the Bytewax Gateway. This can be done in the Swarm yaml definition as shown below.

  - name: hello
    type: python
    input:
      type: gateway
      name: hello-world
    spec:
      image: registry.bytewax.net/hello-world:v0.5.0
      file: hello.py
      bee: hello 

This configuration instructs our first Bee to listen for messages sent to the Gateway under the hello-world subject.

from bytewax import Gateway
gateway = Gateway()
print(gateway.request({'name':'Bee'}, gateway = 'hello-world'))

Here is an example that uses our Gateway SDK object. In this example we are using it to send the payload {'name':'Bee'} using the request method. The request method sends the payload and waits for a response.

Another possible method to send data to a Gateway is the submit() method, which will send data, close the connection and not wait for a response. This is useful for Swarms that publish to a data store or another system where a response is not needed.