11"""
22FSContext module provides a context object that manages configuration access for FunctionStream SDK.
3+
4+ This module defines the FSContext class which serves as a wrapper around the Config object,
5+ providing a clean interface for accessing configuration values and handling any potential
6+ errors during access. It also provides methods for metadata access and data production.
37"""
48
59import logging
610from typing import Any , Dict
11+ from datetime import datetime
712
813from .config import Config
914
@@ -17,6 +22,7 @@ class FSContext:
1722
1823 This class serves as a wrapper around the Config object, providing a clean interface
1924 for accessing configuration values and handling any potential errors during access.
25+ It also provides methods for metadata access and data production capabilities.
2026
2127 Attributes:
2228 config (Config): The configuration object containing all settings.
@@ -25,11 +31,10 @@ class FSContext:
2531
2632 def __init__ (self , config : Config ):
2733 """
28- Initialize the FSContext with a configuration object and optional FSFunction reference .
34+ Initialize the FSContext with a configuration object.
2935
3036 Args:
3137 config (Config): The configuration object to be used by this context.
32- function (FSFunction, optional): The parent FSFunction instance.
3338 """
3439 self .config = config
3540
@@ -53,8 +58,53 @@ def get_config(self, config_name: str) -> Any:
5358 logger .error (f"Error getting config { config_name } : { str (e )} " )
5459 return ""
5560
61+ def get_metadata (self , key : str ) -> Any :
62+ """
63+ Get metadata value by key.
64+
65+ This method retrieves metadata associated with the current message.
66+
67+ Args:
68+ key (str): The metadata key to retrieve.
69+
70+ Returns:
71+ Any: The metadata value, currently always None.
72+ """
73+ return None
74+
75+ def produce (self , data : Dict [str , Any ], event_time : datetime = None ) -> None :
76+ """
77+ Produce data to the output stream.
78+
79+ This method is intended to send processed data to the output stream.
80+
81+ Args:
82+ data (Dict[str, Any]): The data to produce.
83+ event_time (datetime, optional): The timestamp for the event. Defaults to None.
84+
85+ Returns:
86+ None: Currently always returns None.
87+ """
88+ return None
89+
5690 def get_configs (self ) -> Dict [str , Any ]:
91+ """
92+ Get all configuration values.
93+
94+ Returns a dictionary containing all configuration key-value pairs.
95+
96+ Returns:
97+ Dict[str, Any]: A dictionary containing all configuration values.
98+ """
5799 return self .config .config
58100
59101 def get_module (self ) -> str :
102+ """
103+ Get the current module name.
104+
105+ Returns the name of the module currently being executed.
106+
107+ Returns:
108+ str: The name of the current module.
109+ """
60110 return self .config .module
0 commit comments