Module spin_sdk.wit.exports
Expand source code
from typing import TypeVar, Generic, Union, Optional, Union, Protocol, Tuple, List, Any, Self
from enum import Flag, Enum, auto
from dataclasses import dataclass
from abc import abstractmethod
import weakref
from ..types import Result, Ok, Err, Some
from ..imports import types
class InboundRedis(Protocol):
@abstractmethod
def handle_message(self, message: bytes) -> None:
"""
The entrypoint for a Redis handler.
Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis_types.Error)`
"""
raise NotImplementedError
class IncomingHandler(Protocol):
@abstractmethod
def handle(self, request: types.IncomingRequest, response_out: types.ResponseOutparam) -> None:
"""
This function is invoked with an incoming HTTP Request, and a resource
`response-outparam` which provides the capability to reply with an HTTP
Response. The response is sent by calling the `response-outparam.set`
method, which allows execution to continue after the response has been
sent. This enables both streaming to the response body, and performing other
work.
The implementor of this function must write a response to the
`response-outparam` before returning, or else the caller will respond
with an error on its behalf.
"""
raise NotImplementedError
Sub-modules
spin_sdk.wit.exports.inbound_redis
spin_sdk.wit.exports.incoming_handler
-
This interface defines a handler of incoming HTTP Requests. It should be exported by components which can respond to HTTP Requests.
Classes
class InboundRedis (*args, **kwargs)
-
Base class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto(Protocol[T]): def meth(self) -> T: ...
Expand source code
class InboundRedis(Protocol): @abstractmethod def handle_message(self, message: bytes) -> None: """ The entrypoint for a Redis handler. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis_types.Error)` """ raise NotImplementedError
Ancestors
- typing.Protocol
- typing.Generic
Methods
def handle_message(self, message: bytes) ‑> None
-
Expand source code
@abstractmethod def handle_message(self, message: bytes) -> None: """ The entrypoint for a Redis handler. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.redis_types.Error)` """ raise NotImplementedError
class IncomingHandler (*args, **kwargs)
-
Base class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto(Protocol[T]): def meth(self) -> T: ...
Expand source code
class IncomingHandler(Protocol): @abstractmethod def handle(self, request: types.IncomingRequest, response_out: types.ResponseOutparam) -> None: """ This function is invoked with an incoming HTTP Request, and a resource `response-outparam` which provides the capability to reply with an HTTP Response. The response is sent by calling the `response-outparam.set` method, which allows execution to continue after the response has been sent. This enables both streaming to the response body, and performing other work. The implementor of this function must write a response to the `response-outparam` before returning, or else the caller will respond with an error on its behalf. """ raise NotImplementedError
Ancestors
- typing.Protocol
- typing.Generic
Subclasses
Methods
def handle(self, request: IncomingRequest, response_out: ResponseOutparam) ‑> None
-
This function is invoked with an incoming HTTP Request, and a resource
response-outparam
which provides the capability to reply with an HTTP Response. The response is sent by calling theresponse-outparam.set
method, which allows execution to continue after the response has been sent. This enables both streaming to the response body, and performing other work.The implementor of this function must write a response to the
response-outparam
before returning, or else the caller will respond with an error on its behalf.Expand source code
@abstractmethod def handle(self, request: types.IncomingRequest, response_out: types.ResponseOutparam) -> None: """ This function is invoked with an incoming HTTP Request, and a resource `response-outparam` which provides the capability to reply with an HTTP Response. The response is sent by calling the `response-outparam.set` method, which allows execution to continue after the response has been sent. This enables both streaming to the response body, and performing other work. The implementor of this function must write a response to the `response-outparam` before returning, or else the caller will respond with an error on its behalf. """ raise NotImplementedError