Function Trigger

Function Triggers are used to define how to trigger a function. Currently, there are two kinds of triggers: HTTP Trigger, and Dapr Trigger. The default trigger is HTTP trigger.

HTTP Trigger

HTTP Trigger triggers a function with an HTTP request. You can define an HTTP Trigger for a function like this:

  1. apiVersion: core.openfunction.io/v1beta2
  2. kind: Function
  3. metadata:
  4. name: function-sample
  5. spec:
  6. serving:
  7. triggers:
  8. http:
  9. port: 8080
  10. route:
  11. rules:
  12. - matches:
  13. - path:
  14. type: PathPrefix
  15. value: /echo

Dapr Trigger

Dapr Trigger triggers a function with events from Dapr bindings or Dapr pubsub. You can define a function with Dapr Trigger like this:

  1. apiVersion: core.openfunction.io/v1beta2
  2. kind: Function
  3. metadata:
  4. name: logs-async-handler
  5. namespace: default
  6. spec:
  7. serving:
  8. bindings:
  9. kafka-receiver:
  10. metadata:
  11. - name: brokers
  12. value: kafka-server-kafka-brokers:9092
  13. - name: authRequired
  14. value: "false"
  15. - name: publishTopic
  16. value: logs
  17. - name: topics
  18. value: logs
  19. - name: consumerGroup
  20. value: logs-handler
  21. type: bindings.kafka
  22. version: v1
  23. triggers:
  24. dapr:
  25. - name: kafka-receiver
  26. type: bindings.kafka

Function Inputs

Input is where a function can get extra input data from, Dapr State Stores is supported as Input currently.

You can define function input like this:

  1. apiVersion: core.openfunction.io/v1beta2
  2. kind: Function
  3. metadata:
  4. name: logs-async-handler
  5. namespace: default
  6. spec:
  7. serving:
  8. triggers:
  9. inputs:
  10. - dapr:
  11. name: mysql
  12. type: state.mysql