# Function Refactoring ```yaml= apiVersion: core.openfunction.io/v1beta1 kind: Function metadata: name: logs-async-handler spec: version: "v2.0.0" image: openfunctiondev/logs-async-handler:v1 imageCredentials: name: push-secret build: builder: openfunction/builder-go:latest env: FUNC_NAME: "LogsHandler" FUNC_CLEAR_SOURCE: "true" # # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules # FUNC_GOPROXY: "https://goproxy.cn" srcRepo: url: "https://github.com/OpenFunction/samples.git" sourceSubPath: "functions/async/logs-handler-function/" revision: "main" serving: trigger: ## type: http.knative ## type: http ## type: pubsub.rabbitmq type: binding.kafka name: kafka component: kafka-receiver outputs: - name: notify component: notification-manager operation: "post" bindings: kafka-receiver: type: bindings.kafka version: v1 metadata: - name: brokers value: "kafka-server-kafka-brokers:9092" - name: authRequired value: "false" - name: publishTopic value: "logs" - name: topics value: "logs" - name: consumerGroup value: "logs-handler" notification-manager: type: bindings.http version: v1 metadata: - name: url value: http://notification-manager-svc.kubesphere-monitoring-system.svc.cluster.local:19093/api/v2/alerts scaleOptions: keda: scaledObject: pollingInterval: 15 minReplicaCount: 0 maxReplicaCount: 10 cooldownPeriod: 60 advanced: horizontalPodAutoscalerConfig: behavior: scaleDown: stabilizationWindowSeconds: 45 policies: - type: Percent value: 50 periodSeconds: 15 scaleUp: stabilizationWindowSeconds: 0 triggers: - type: kafka metadata: topic: logs bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092 consumerGroup: logs-handler lagThreshold: "20" template: containers: - name: function # DO NOT change this imagePullPolicy: IfNotPresent ``` # Build ```yaml= apiVersion: core.openfunction.io/v1beta1 kind: Build metadata: name: sample-build spec:: image: openfunctiondev/logs-async-handler:v1 imageCredentials: name: push-secret builder: openfunction/builder-go:latest timeout: 5m successfulBuildsHistoryLimit: 5 failedBuildsHistoryLimit: 10 builderMaxAge: 60m env: FUNC_NAME: "LogsHandler" FUNC_CLEAR_SOURCE: "true" # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules # FUNC_GOPROXY: "https://goproxy.cn" srcRepo: url: "https://github.com/OpenFunction/samples.git" sourceSubPath: "functions/async/logs-handler-function/" revision: "main" ```