Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions functions/example-external.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# limitations under the License.

name: external-function
namespace: fs
namespace: function-stream
runtime:
type: "external"
sources:
- config:
inputs:
- "external-input"
subscription-name: "fs"
subscription-name: "function-stream"
type: "memory"
sink:
config:
Expand Down
4 changes: 2 additions & 2 deletions functions/example-functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

name: function-sample
namespace: fs
namespace: function-stream
runtime:
type: "wasm"
config:
Expand All @@ -22,7 +22,7 @@ sources:
- config:
inputs:
- "input"
subscription-name: "fs"
subscription-name: "function-stream"
type: "memory"
sink:
config:
Expand Down
17 changes: 17 additions & 0 deletions operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,12 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
CODEGEN ?= $(LOCALBIN)/code-generator

## Tool Versions
KUSTOMIZE_VERSION ?= v5.6.0
CONTROLLER_TOOLS_VERSION ?= v0.17.2
CODEGEN_VERSION ?= v0.32.1
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
Expand Down Expand Up @@ -216,6 +218,21 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

.PHONY: code-generator
code-generator: $(CODEGEN) ## Download code-generator locally if necessary.
$(CODEGEN): $(LOCALBIN)
$(call go-install-tool,$(CODEGEN),k8s.io/code-generator/cmd/...,$(CODEGEN_VERSION))

.PHONY: generate-client
generate-client: ## Generate client SDK using code-generator
@echo "Generating client SDK..."
@mkdir -p pkg/client
@go install k8s.io/code-generator/cmd/client-gen@v0.32.1
@go install k8s.io/code-generator/cmd/lister-gen@v0.32.1
@go install k8s.io/code-generator/cmd/informer-gen@v0.32.1
@go install k8s.io/code-generator/cmd/deepcopy-gen@v0.32.1
@hack/update-codegen.sh

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary
# $2 - package url which can be installed
Expand Down
2 changes: 1 addition & 1 deletion operator/deploy/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ controllerManager:
image:
repository: functionstream/operator
tag: latest
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
args:
- "--leader-elect"
- "--metrics-bind-address=:8443"
Expand Down
3 changes: 3 additions & 0 deletions sdks/fs-python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
build-image:
docker build -t functionstream/fs-python-base .

docker-buildx:
docker buildx build --platform linux/amd64,linux/arm64 -t functionstream/fs-python-base .

test:
PYTHONPATH=. python -m pytest
2 changes: 1 addition & 1 deletion sdks/fs-python/function_stream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .metrics import Metrics, MetricsServer
from .module import FSModule

__version__ = "0.6.0rc1"
__version__ = "0.6.0rc2"
__all__ = [
# Core classes
"FSFunction",
Expand Down
54 changes: 52 additions & 2 deletions sdks/fs-python/function_stream/context.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
"""
FSContext module provides a context object that manages configuration access for FunctionStream SDK.

This module defines the FSContext class which serves as a wrapper around the Config object,
providing a clean interface for accessing configuration values and handling any potential
errors during access. It also provides methods for metadata access and data production.
"""

import logging
from typing import Any, Dict
from datetime import datetime

from .config import Config

Expand All @@ -17,6 +22,7 @@ class FSContext:

This class serves as a wrapper around the Config object, providing a clean interface
for accessing configuration values and handling any potential errors during access.
It also provides methods for metadata access and data production capabilities.

Attributes:
config (Config): The configuration object containing all settings.
Expand All @@ -25,11 +31,10 @@ class FSContext:

def __init__(self, config: Config):
"""
Initialize the FSContext with a configuration object and optional FSFunction reference.
Initialize the FSContext with a configuration object.

Args:
config (Config): The configuration object to be used by this context.
function (FSFunction, optional): The parent FSFunction instance.
"""
self.config = config

Expand All @@ -53,8 +58,53 @@ def get_config(self, config_name: str) -> Any:
logger.error(f"Error getting config {config_name}: {str(e)}")
return ""

def get_metadata(self, key: str) -> Any:
"""
Get metadata value by key.

This method retrieves metadata associated with the current message.

Args:
key (str): The metadata key to retrieve.

Returns:
Any: The metadata value, currently always None.
"""
return None

def produce(self, data: Dict[str, Any], event_time: datetime = None) -> None:
"""
Produce data to the output stream.

This method is intended to send processed data to the output stream.

Args:
data (Dict[str, Any]): The data to produce.
event_time (datetime, optional): The timestamp for the event. Defaults to None.

Returns:
None: Currently always returns None.
"""
return None

def get_configs(self) -> Dict[str, Any]:
"""
Get all configuration values.

Returns a dictionary containing all configuration key-value pairs.

Returns:
Dict[str, Any]: A dictionary containing all configuration values.
"""
return self.config.config

def get_module(self) -> str:
"""
Get the current module name.

Returns the name of the module currently being executed.

Returns:
str: The name of the current module.
"""
return self.config.module
Loading
Loading