api:
  enabled: true
  port: 8080
modules:
  - id: sqlite
    type: db.sqlite
    params:
      dsn: ":memory:"
  - id: httpin
    type: http.server
    params:
      port: 3000
  - id: tcpout
    type: net.tcp.client
    params:
      host: "localhost"
      port: 9000
      framing: "RAW"
  - id: tcpin
    type: net.tcp.server
    params:
      port: 9000
      framing: "RAW"
  - id: ticker
    type: time.interval
    params:
      duration: 1000
  - id: udpout
    type: net.udp.client
    params:
      host: "localhost"
      port: 9001
  - id: udpin
    type: net.udp.server
    params:
      port: 9001
  - id: wsecho
    type: websocket.client
    params:
      url: "wss://echo.websocket.org"
  - id: natsserver
    type: nats.server
    params:
      port: 4222
  - id: natsout
    type: nats.client
    params:
      url: "nats://localhost:4222"
      subject: "hello"
  - id: natsin
    type: nats.client
    params:
      url: "nats://localhost:4222"
      subject: "test"
routes:
  - input: ticker
    processors:
      - type: string.create
        params:
          template: "wsecho: {{.Payload.UnixMilli}}"
      - type: module.output
        params:
          module: wsecho
  - input: ticker
    processors:
      - type: string.create
        params:
          template: "tcpout: {{.Payload.UnixMilli}}"
      - type: string.encode
      - type: module.output
        params:
          module: tcpout
  - input: ticker
    processors:
      - type: string.create
        params:
          template: "udpout: {{.Payload.UnixMilli}}"
      - type: string.encode
      - type: module.output
        params:
          module: udpout
  - input: ticker
    processors:
      - type: http.request.do
        params:
          url: "http://localhost:3000/echo"
          method: "GET"
      - type: struct.field.get
        params:
          name: "Body"
      - type: string.decode
      - type: debug.log
  - input: tcpin
    processors:
      - type: string.decode
      - type: debug.log
  - input: udpin
    processors:
      - type: string.decode
      - type: debug.log
  - input: wsecho
    processors:
      - type: debug.log
  - input: ticker
    processors:
      - type: db.query
        params:
          module: "sqlite"
          query: "SELECT 1;"
      - type: debug.log
  - input: natsin
    processors:
      - type: struct.field.get
        params:
          name: "Data"
      - type: string.decode
      - type: debug.log
  - input: httpin
    processors:
      - type: http.response.create
        params:
          status: 200
          bodyTemplate: "Hello, World!"
      - type: module.output
        params:
          module: httpin
  - input: ticker
    processors:
      - type: string.create
        params:
          template: "natsout: {{.Payload}}"
      - type: pubsub.publish
        params:
          module: natsout
          topic: "test"
