Contexts
Last updated
Was this helpful?
Last updated
Was this helpful?
Contexts provide a way for nodes to implicitly pass values along an execution path, eliminating the need for explicit connections. For example, when an node receives a request, it automatically makes an EndpointContext
available to nodes it connects to. This allows an node to access and respond to the request without requiring you to explicitly pass a request object.
Some input triggers require specific contexts to function. These triggers either consume or borrow contexts:
Consuming a context means it can only be used once. For example, Http.Response.execute
consumes an EndpointContext
, ensuring that a request can only be responded to once.
Borrowing a context means it can be used multiple times without consuming it. For example, Testing.AssertEqual.execute
borrows a TestContext
, allowing multiple assertions within the same test.
Some examples of functions in the standard library using contexts
provides an EndpointContext
, representing the incoming HTTP request, which is then consumed by the first call to .
provides a TestContext
, representing a running test instance. This context is then borrowed by assertion functions like .
provides a context which keeps track of the current loop index.
If your own functions use functions that require certain contexts, you need to explicitly add those contexts to your own functions triggers as well. If you for example want to perform an call in your function, you need consume an EndpointContext.
EndpointContext
.