Session¶
diffusion.session ¶
Public session for end users.
Session ¶
The client session to a server or cluster of servers.
Notes
A session can be created by connecting to a server using SessionFactory.open(server_url: str), specifying the server URL. The session factory can be configured to control the behavior of the session.
The session provides a variety of operations to the application. These are grouped into feature interfaces, such as Topics and Messaging, exposed to the application through various properties.
Session lifecycle¶
Each session is managed by a server. The server assigns the session a unique identity session_id and manages the session's topic subscriptions, security details, and session properties.
A session can be terminated using close. A session may also be terminated by the server because of an error or a time out, or by other privileged sessions using the ClientControl feature.
The current state of the session can be retrieved with the state property. A
listener can be registered with the state_changed
event which will be notified when
the session state changes.
Session Properties¶
For each session, the server stores a set of session properties that describe various attributes of the session.
There are two types of session property. Fixed properties are assigned by the server. User-defined properties are assigned by the application.
Many operations use session filter expressions that use session properties to select sessions.
Each property is identified by a key. Most properties have a single string values.
Fixed properties are identified by keys with a $ prefix. The available fixed session properties are:
Key | Description |
---|---|
$ClientIP() |
The Internet address of the client in string format. |
$ClientType() |
The client type of the session. One of ANDROID , C , DOTNET , IOS , JAVA , JAVASCRIPT_BROWSER , MQTT , PYTHON , REST , or OTHER . |
$Environment() |
The environment in which the client is running. For possible values see the user manual. |
$Connector() |
The configuration name of the server connector that the client connected to. |
$Country() |
The country code for the country where the client's Internet address was allocated (for example, NZ for New Zealand). If the country code could not be determined, this will be a zero length string. |
$GatewayType() |
Gateway client type. Only set for gateway client sessions. If present it indicates the type of gateway client (e.g. Kafka). |
$GatewayId() |
The identity of a gateway client session. Only present if the $GatewayType session property is present. |
$Language() |
The language code for the official language of the country where the client's Internet address was allocated (for example, en for English). If the language could not be determined or is not applicable, this will be a zero length string. |
$Latitude() |
The client's latitude, if available. This will be the string representation of a floating point number and will be NaN if not available. |
$Longitude() |
The client's longitude, if available. This will be the string representation of a floating point number and will be NaN if not available. |
$MQTTClientId() |
The MQTT client identifier. Only set for MQTT sessions. If present, the value of the $ClientType session property will be MQTT . |
$Principal() |
The security principal associated with the client session. |
$Roles() |
Authorisation roles assigned to the session. This is a set of roles represented as quoted strings (for example, "role1","role2" ). The utility method can be used to parse the string value into a set of roles. |
$ServerName() |
The name of the server to which the session is connected. |
$SessionId() |
TThe session identifier. Equivalent to str( x.session_id ) , where x is a Session. |
$StartTime() |
The session's start time in milliseconds since the epoch. |
$Transport() |
The session transport type. One of WEBSOCKET , HTTP_LONG_POLL , TCP , or OTHER . |
All listed property keys constants can be found in SessionProperty
.
All user-defined property keys are non-empty strings and are case-sensitive. The
characters ' '
, '\t'
, '\r'
, '\n'
, '\"'
, '\''
, '('
, ')'
are not allowed.
Session properties are initially associated with a session as follows:
-
When a client starts a session, it can optionally propose user-defined session properties (see SessionFactory.properties). Session properties proposed in this way must be accepted by the authenticator. This safeguard prevents abuse by a rogue, unprivileged client.
-
The server allocates all fixed property values.
-
The session is authenticated by registered authenticators. An authenticator that accepts a session can veto or change the user-defined session properties and add user-defined session properties. The authenticator can also change certain fixed properties.
Session Filters¶
Session filters are a mechanism of addressing a set of sessions by the values of their session properties.
Session filters are specified using a Domain Specific Language (DSL). For a full and detailed description of the session filters DSL see the user manual.
Session locks¶
The actions of multiple sessions can be coordinated using session locks. See SessionLock.
Note: This interface does not require user implementation and is only used to hide implementation details.
Note: Added in 6.6
Example:
session = diffusion.sessions().open("ws://localhost:8080")
__init__ ¶
__init__(
url: StrictStr,
principal: Optional[str] = None,
credentials: Optional[Credentials] = None,
properties: Optional[typing.Mapping[str, str]] = None,
connection_factory: Optional[ConnectionFactory] = None,
internal_session_factory: Optional[
typing.Callable[
[
typing.Union[
AbstractConnection, ConnectionFactory
]
],
InternalSession,
]
] = None,
attributes: typing.Optional[SessionAttributes] = None,
)
A client session connected to a Diffusion server or a cluster of servers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
StrictStr
|
WebSockets URL of the Diffusion server to connect to. |
required |
principal
|
Optional[str]
|
The name of the security principal associated with the session. |
None
|
credentials
|
Optional[Credentials]
|
Security information required to authenticate the connection. |
None
|
properties
|
Optional[typing.Mapping[str, str]]
|
Session Properties. |
None
|
connection_factory
|
Optional[ConnectionFactory]
|
Connection factory, for internal use. |
None
|
internal_session_factory
|
Optional[typing.Callable[[typing.Union[AbstractConnection, ConnectionFactory]], InternalSession]]
|
Internal session factory, for internal use. |
None
|
attributes
|
typing.Optional[SessionAttributes]
|
Session attributes. |
None
|
The recommended method is to instantiate this class as an async context manager. Here is a minimal example:
>>> async with diffusion.Session("ws://diffusion.server:8080") as session:
... # do some work with the session
... pass
The context manager will make sure that the connection is properly closed at the end of the program. Alternatively, it is possible to open the connection explicitly, which can be useful if the session needs to be passed around, in this case the connection needs to be explicitly closed as well:
connect
async
¶
connect(properties: Optional[SessionProperties] = None)
Connect to the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
properties
|
Optional[SessionProperties]
|
A dict of Diffusion session properties to set and/or update at connection. |
None
|
lock
async
¶
lock(
lock_name: str,
scope: SessionLockScope = SessionLockScope.UNLOCK_ON_SESSION_LOSS,
) -> SessionLock
Attempts to acquire a SessionLock with a given scope.
Notes
If the operation completes successfully, the result will be the requested SessionLock assigned to the calling session by the server. The session owns the returned lock and is responsible for unlocking it.
Acquiring the lock can take an arbitrarily long time if other sessions are competing for the lock. The server will retain the session's request for the lock until it is assigned to the session, the session is closed.
A session can call this method multiple times. If the lock is acquired, all calls will complete successfully with equal SessionLock.
A session that acquires a lock will remain its owner until it is unlocked (via SessionLock.unlock) or the session closes.
If called with a scope
of
SessionLockScope.UNLOCK_ON_SESSION_LOSS,
this method behaves exactly like SessionLocks.lock.
If called with a scope
of
SessionLockScope.UNLOCK_ON_CONNECTION_LOSS,
any lock that is returned will be unlocked
if the session loses its connection to the server.
This is useful to allow another session to take ownership of the lock
while this session is reconnecting.
If a session makes multiple requests for a lock using different scopes, and the server assigns the lock to the session fulfilling the requests, the lock will be given the weakest scope (SessionLockScope.UNLOCK_ON_CONNECTION_LOSS).
Access control¶
To allow fine-grained access control, lock names are interpreted as path names, controlled with the update-topic/b, for example.
Since
6.10.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lock_name
|
str
|
The name of the session lock. |
required |
scope
|
SessionLockScope
|
The scope of the session lock. |
SessionLockScope.UNLOCK_ON_SESSION_LOSS
|
Returns: A session lock object.
on_state_changed
async
¶
Raises the StateChanged event from session. Bound as a handler on the InternalSession.on_state_changed event.
remove_listener ¶
remove_listener(listener: SessionListener)
Remove a given session state listener from the session Args: listener: the listener to remove
Raises:
Type | Description |
---|---|
InvalidOperationError
|
if no such listener is present |
SessionListener ¶
exceptions ¶
SessionError ¶
Bases: DiffusionError
A Diffusion Session Error.
IncompatibleTopicError ¶
UpdateFailedError ¶
NoSuchTopicError ¶
NoTopicFoundError ¶
NoSuchEventError ¶
Bases: SessionError
The exception used to report a time series topic does not have an original event with the sequence number provided by an
See Also
timeseries.edit operation.
Notes
Added in version 6.9.
ExistingTopicError ¶
InvalidTopicPathError ¶
InvalidTopicSpecificationError ¶
TopicLicenseLimitError ¶
IncompatibleExistingTopicError ¶
Bases: SessionError
This differs from ExistingTopicError as the reason is that the existing topic is owned by something that prevents the caller managing. The specification of the existing topic may be the same.
AddTopicError ¶
UnsatisfiedConstraintError ¶
ExclusiveUpdaterConflictError ¶
Bases: SessionError
The exception to indicate an update could not be applied because an exclusive update source is registered for the path.
InvalidPatchError ¶
FailedPatchError ¶
Bases: SessionError
The exception to report that applying a JSON Patch failed.
Notes
This can happen if the topic's current value is not valid CBOR. See VALIDATE_VALUES.
InvalidUpdateStreamError ¶
Bases: SessionError
The exception used to report an operation was performed with an invalid [UpdateStream][diffusion.UpdateStream].
NotATimeSeriesTopicError ¶
IncompatibleTopicStateError ¶
Bases: SessionError
The exception that indicates that an operation could not be performed because the topic is managed by a component (such as fan-out) that prohibits updates from the caller.
InvalidQueryError ¶
Bases: SessionError
Exception used to report a query that is invalid for the time series.
Notes
An example invalid query is one where the anchor is a sequence number
beyond the end of the time series (for example, it is specified using
RangeQuery.from_(anchor: StrictNonNegativeInt)
with a sequence number greater than the latest sequence number, or
RangeQuery.from_last(offset: StrictNonNegativeInt)
with a count
greater than the number of events in the time series),
and the span is a relative time. Since no timestamp is associated
with the anchor, the range is meaningless.
Added in version 6.9.
SessionClosedError ¶
Bases: SessionError
The exception indicating a ISession closure.
Notes
No further operations are possible when this exception has been thrown.
Added in 6.9
SessionSecurityError ¶
Bases: SessionError
The exception indicating that a ISession operation failed due to a security constraint.
Notes
Repeating the operation with the same security credentials is likely to fail.
Added in 6.9
FatalConnectionError ¶
Bases: ProtocolError
The exception indicating a connection has been rejected and should not be retried.
Notes
This exception is never thrown directly but might be the cause of a SessionError
Added in 6.9
AuthenticationError ¶
Bases: FatalConnectionError
The connection exception representing an authentication failure.
Notes
This exception is never thrown directly but might be the cause of a SessionError
Added in 6.9
ProxyAuthenticationError ¶
Bases: ProtocolError
The exception indicating that there was a problem during authentication with a proxy server.
Notes
This exception is never thrown directly but might be the cause of a SessionError
Added in 6.9.
locks ¶
session_lock_acquisition ¶
SessionLockScope ¶
Values for the scope
parameter of
Session.lock
Since
6.10
session_locks ¶
SessionLock ¶
Bases: object
A Session lock.
Notes
A session lock is a server-managed resource that can be used to coordinate exclusive access to shared resources across sessions. For example, to ensure a single session has the right to update a topic; to ensure at most one session responds to an event; or to select a single session to perform a housekeeping task. Session locks support general collaborative locking schemes. The application architect is responsible for designing a suitable locking scheme and for ensuring each application component follows the scheme appropriately.
Session locks are identified by a lock name. Lock names are arbitrary and chosen at will to suit the application. Each lock is owned by at most one session. Locks are established on demand; there is no separate operation to create or destroy a lock.
A session lock is acquired using the Session.lock method. If no other session owns the lock, the server will assign the lock to the calling session immediately. Otherwise, the server will record that the session is waiting to acquire the lock. A session can call Session.lock more than once for a given session lock – if the lock is acquired, all calls will complete successfully with equal SessionLock values.
If a session closes, the session locks it owns are automatically released. A session can also release a lock by calling SessionLock.unlock. When a session lock is released and other sessions are waiting to acquire the lock, the server will arbitrarily select one of the waiting sessions and notify it that it has acquired the lock. All of the newly selected session's pending Session.lock calls will complete normally. Other sessions will continue to wait.
The Session.lock variant of this method takes a scope parameter that provides the further option of automatically releasing the lock when the session loses its connection to the server.
Race conditions¶
This session lock API has inherent race conditions. Even if an application is coded correctly to protect a shared resource using session locks, there may be a period where two or more sessions concurrently access the resource. The races arise for several reasons including
-
Due to the check-then-act approach of polling
, the lock can be lost after the check has succeeded but before the resource is accessed; -
The server can detect a session is disconnected and assign the lock to another session before the original session has detected the disconnection.
Despite this imprecision, session locks provide a useful way to coordinate session actions.
NOTE This interface does not require user implementation and is only used to hide implementation details.
Since: 6.10
SessionLocks ¶
Bases: object
__init__ ¶
Initializes a new SessionLocks
Parameters:
Name | Type | Description | Default |
---|---|---|---|
internal_session
|
InternalSession
|
The internal session. |
required |
lock
async
¶
lock(
lock_name: pydantic.StrictStr, scope: SessionLockScope
) -> "SessionLock"
Sends a lock request to the server.
Notes
If the operation completes successfully, the result will be a new SessionLock.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lock_name
|
pydantic.StrictStr
|
The name of the lock. |
required |
scope
|
SessionLockScope
|
The scope of the lock. |
required |
Returns: A session lock object.
post_commit
async
¶
Hook that runs immediately after internal lock committal.
Primarily used for testing.
unlock
async
¶
unlock(session_lock: SessionLock) -> bool
Sends an unlock request to the server and releases the given session lock.
Notes
If the operation completes successfully, the result will be a
bool
indicating whether the server released the given
SessionLock.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_lock
|
SessionLock
|
The session lock to release. |
required |
Returns:
True
if successful, otherwise False
.
properties ¶
ALL_FIXED_PROPERTIES
module-attribute
¶
This constant can be used instead of a property key in requests for session property values to indicate that all fixed session properties are required.
ALL_USER_PROPERTIES
module-attribute
¶
This constant can be used instead of a property key in requests for session property values to indicate that all user defined session properties are required.
retry_strategy ¶
RetryStrategy ¶
Bases: pydantic.BaseModel
Defines a retry strategy.
A retry strategy will be applied when an initial to attempt to open a session fails with a ServerConnectionError.
The strategy is defined in terms of the number of seconds between retries and the maximum number of retries to attempt.
Since
6.9
session_attributes ¶
SessionAttributes
dataclass
¶
Bases: object
The attributes of a Session.
Notes
These attributes will be set by SessionFactory. This interface does not require user implementation and is only used to hide implementation details.
Notes
Added in 6.11
DEFAULT_MAXIMUM_MESSAGE_SIZE
class-attribute
¶
DEFAULT_MAXIMUM_MESSAGE_SIZE: MaximumResultSize = (
typing.cast(MaximumResultSize, Int32.max_signed_int())
)
The default maximum message size in bytes. The maximum message size limits the size of received messages. This default value is is Int32.max_signed_int, so the message size is effectively unlimited.
Notes
Since: 6.11
initial_retry_strategy
class-attribute
instance-attribute
¶
initial_retry_strategy: RetryStrategy = dataclasses.field(
default_factory=_no_retry_strategy
)
Returns the initial retry strategy.
Returns:
Type | Description |
---|---|
RetryStrategy
|
the initial retry strategy used by the session |
Since
6.9
ssl_context
class-attribute
instance-attribute
¶
ssl_context: typing.Optional[ssl.SSLContext] = None
The SSL context for secure connections. Returns the SSL context for secure connections.
See Also
Returns:
Type | Description |
---|---|
typing.Optional[ssl.SSLContext]
|
the SSL context |
Since
6.11
maximum_message_size
class-attribute
instance-attribute
¶
maximum_message_size: MaximumResultSize = (
DEFAULT_MAXIMUM_MESSAGE_SIZE
)
Returns the maximum message size that will be accepted by this session.
See Also
SessionFactory#maximumMessageSize(int)
Returns:
Type | Description |
---|---|
MaximumResultSize
|
the maximum message size |
Since
6.11
server_host
class-attribute
instance-attribute
¶
server_host: str = 'localhost'
Returns the host name or IP of the server the session will connect to.
See Also
Returns:
Type | Description |
---|---|
str
|
the host name (or IP address) |
Since
6.9
server_port
class-attribute
instance-attribute
¶
server_port: int = 8080
Returns the port of the server the session will connect to.
See Also
Returns:
Type | Description |
---|---|
int
|
the port |
Since
6.9
secure_transport
class-attribute
instance-attribute
¶
session_factory ¶
SessionProperties
module-attribute
¶
Mapping of session properties
SessionEstablishmentException ¶
Bases: DiffusionError
Session establishment error
Connector
dataclass
¶
Bases: object
Connector object.
This can be awaited to return a connected session, or used as an asynchronous context manager that provides a connected session on entry and closes it on exit. This is used by the SessionFactory and is not designed for manual creation.
session_details
instance-attribute
¶
The session details involved
container_factory
instance-attribute
¶
The factory responsible for building the session and connecting it
url
instance-attribute
¶
The URL to be connected to. If not present the session details will be used instead.
__init__ ¶
__init__(
session_details: SessionDetails,
container_factory: SessionContainerFactory,
session_attributes: SessionAttributes,
)
This is used by the SessionFactory and is not designed for manual creation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_details
|
SessionDetails
|
the session details involved |
required |
container_factory
|
SessionContainerFactory
|
responsible for building the session and connecting it |
required |
session_attributes
|
SessionAttributes
|
the Session Attributes to use |
required |
SessionFactory ¶
Bases: object
Factory for client diffusion.session.Session.
Each instance is immutable, and has a number of session attributes that determine how sessions should be established. An initial instance of this factory with default values for all attributes can be obtained from diffusion.sessions(). Each method returns a copy of this factory, with a single changed attribute.
Establishing a session¶
A new session can be created using open specifying a URL that identifies the server. This returns an async context manager, which will provide the connected Session object.
The server is identified by the diffusion.session.session_factory.SessionFactory.server_host and diffusion.session.session_factory.SessionFactory.server_port attributes.
If a URL is specified, it takes precedence over the diffusion.session.session_factory.SessionFactory.server_host and diffusion.session.session_factory.SessionFactory.server_port session factory attributes.
URL format¶
URLs should take the form scheme://host:port, where scheme is chosen from the following table and determines the transport protocol used to send Diffusion messages.
Scheme | Transport Protocol |
---|---|
ws |
WebSocket. See https://tools.ietf.org/html/rfc6455 |
wss |
WebSocket over TLS. |
We recommend using the WebSocket protocol options ws
or
wss
.
TLS is Transport Layer Security, commonly known as SSL. TLS-based protocols use cryptography to provide transport-level privacy, authentication, and integrity, and protects against network-sniffing and man-in-the-middle attacks. We recommend using the TLS variants for all communication. For a typical application, you should only consider not using TLS for unauthenticated ("anonymous") client sessions.
Since
6.9
principal ¶
principal(principal: str) -> SessionFactory
Sets the security principal.
By default, this will be diffusion.session.ANONYMOUS_PRINCIPAL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
principal
|
str
|
the principal |
required |
Returns:
Type | Description |
---|---|
SessionFactory
|
a new immutable instance of the factory with the principal changed |
credentials ¶
credentials(credentials: Credentials) -> SessionFactory
Set credentials.
The default is None
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
credentials
|
Credentials
|
the credentials |
required |
Returns:
Type | Description |
---|---|
SessionFactory
|
a new immutable instance of the factory with the credentials changed |
initial_retry_strategy ¶
initial_retry_strategy(
strategy: RetryStrategy,
) -> SessionFactory
Sets the initial retry strategy.
The strategy will determine whether a failure to open a session due to a ServerConnectionError should be retried and if so, at what interval and for how many attempts.
If no initial retry strategy is set there will be no attempt to retry after such a failure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strategy
|
RetryStrategy
|
strategy the retry strategy to use |
required |
Returns:
Type | Description |
---|---|
SessionFactory
|
a new immutable instance of the factory with the initial retry strategy changed |
Since
6.9
secure_transport ¶
secure_transport(secure_transport: bool) -> SessionFactory
Sets whether to use secure transport or not If not explicitly supplied, secure transport will not be used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
secure_transport
|
bool
|
whether to use secure transport |
required |
Returns:
Type | Description |
---|---|
SessionFactory
|
a new immutable instance of the factory with the secure transport flag changed |
Since
6.11
maximum_message_size ¶
maximum_message_size(
size_in_bytes: MaximumResultSize,
) -> SessionFactory
Sets the maximum message size.
This constrains the size of messages that will be accepted from the server and thus the size of any content that can be received. The limit is simply to protect against unexpectedly large messages.
The given size_in_bytes
must not be less than
SessionAttributes.MAXIMUM_MESSAGE_SIZE_MIN.
By default, the size of received messages is unconstrained; see SessionAttributes.DEFAULT_MAXIMUM_MESSAGE_SIZE
Notes
Added in 6.11
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size_in_bytes
|
MaximumResultSize
|
The maximum message size in bytes. |
required |
Returns: A new immutable instance of this factory with the maximum message size changed.
Raises:
Type | Description |
---|---|
ValueError
|
size_in_bytes is not a positive integer between SessionAttributes.MAXIMUM_MESSAGE_SIZE_MIN and SessionAttributes.DEFAULT_MAXIMUM_MESSAGE_SIZE. |
Examples:
Setting the maximum message size to 10 MiB.
ssl_context ¶
ssl_context(context: SSLContext) -> SessionFactory
Sets the SSL Context if a secure connection is required.
If not explicitly supplied, the ssl.SSLContext(protocol=ssl.PROTOCOL_TLS) default context will be used.
Setting the SSL Context will not enable transport layer security. It must also be specified by the URL or SessionFactory.secure_transport.
Returns:
Type | Description |
---|---|
SessionFactory
|
a new immutable instance of the factory with the SSL context changed |
Since
6.11
server_host ¶
server_host(
host: diffusion.internal.pydantic_compat.v1.StrictStr,
) -> SessionFactory
Set the host name of the server to connect the session to.
This value is only used if a URL is not provided when opening a session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
host
|
diffusion.internal.pydantic_compat.v1.StrictStr
|
the host name of the server |
required |
Returns:
Type | Description |
---|---|
SessionFactory
|
a new immutable instance of the factory that will use the provided host |
Raises:
Type | Description |
---|---|
IllegalArgumentError
|
if the specified |
server_port ¶
server_port(port: int) -> SessionFactory
Set the port of the server to connect the session to.
This value is only used if a URL is not provided when opening a session. If the port is not set using this method or a URL, the port will be inferred based on the transport and security configuration.
The provided value must be within the range used for port numbers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port
|
int
|
the port of the server |
required |
Returns:
Type | Description |
---|---|
SessionFactory
|
a new immutable instance of the factory that will use the provided port |
Raises:
IllegalArgumentError: if the specified port
is invalid
properties ¶
properties(properties: SessionProperties) -> SessionFactory
Sets user-defined session property values.
Supplied session properties will be provided to the server when a session is created using this session factory. The supplied properties will be validated during authentication and may be discarded or changed.
The specified properties will be added to any existing properties set for this session factory. If any of the keys have been previously declared then they will be overwritten with the new values.
For details of how session properties are used see diffusion.session.Session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
properties
|
SessionProperties
|
a map of user-defined session properties |
required |
Returns:
Type | Description |
---|---|
SessionFactory
|
a new immutable instance of the factory with the supplied properties set |
Since
6.9
open ¶
This method returns a diffusion.session.session_factory.Connector instance.
Awaiting this object via await
will open a connection
to a server and return a new, connected Session.
Using it as an async context manager via async with
wil
do the same on entry and close this Session on exit.
It can take a URL to specify the server location, ignoring the diffusion.session.session_factory.SessionFactory.server_host and diffusion.session.session_factory.SessionFactory.server_port session factory attributes.
Raises:
Type | Description |
---|---|
IllegalArgumentError
|
if |
IllegalStateError
|
if any of the session attributes are found to be inconsistent. For example, if the default SSL context could not be loaded |
SessionEstablishmentError
|
if an initial connection could not be established |
AuthenticationError
|
if the client is insufficiently authorized to start the session, based on the supplied client credentials. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
typing.Optional[str]
|
the server location |
None
|
Returns:
Type | Description |
---|---|
Connector
|
Since
6.9
sessions
cached
¶
sessions(
container_factory: typing.Optional[
SessionContainerFactory
] = None,
) -> SessionFactory
Returns:
Type | Description |
---|---|
SessionFactory
|
The default session factory. |
diffusion.internal.session.Credentials ¶
Simple wrapper class to encapsulate server credentials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Union[str, bytes]
|
value: The value of the credentials. |
b''
|
Examples:
diffusion.session.exceptions ¶
SessionError ¶
Bases: DiffusionError
A Diffusion Session Error.
IncompatibleTopicError ¶
UpdateFailedError ¶
NoSuchTopicError ¶
NoTopicFoundError ¶
NoSuchEventError ¶
Bases: SessionError
The exception used to report a time series topic does not have an original event with the sequence number provided by an
See Also
timeseries.edit operation.
Notes
Added in version 6.9.
ExistingTopicError ¶
InvalidTopicPathError ¶
InvalidTopicSpecificationError ¶
TopicLicenseLimitError ¶
IncompatibleExistingTopicError ¶
Bases: SessionError
This differs from ExistingTopicError as the reason is that the existing topic is owned by something that prevents the caller managing. The specification of the existing topic may be the same.
AddTopicError ¶
UnsatisfiedConstraintError ¶
ExclusiveUpdaterConflictError ¶
Bases: SessionError
The exception to indicate an update could not be applied because an exclusive update source is registered for the path.
InvalidPatchError ¶
FailedPatchError ¶
Bases: SessionError
The exception to report that applying a JSON Patch failed.
Notes
This can happen if the topic's current value is not valid CBOR. See VALIDATE_VALUES.
InvalidUpdateStreamError ¶
Bases: SessionError
The exception used to report an operation was performed with an invalid [UpdateStream][diffusion.UpdateStream].
NotATimeSeriesTopicError ¶
IncompatibleTopicStateError ¶
Bases: SessionError
The exception that indicates that an operation could not be performed because the topic is managed by a component (such as fan-out) that prohibits updates from the caller.
InvalidQueryError ¶
Bases: SessionError
Exception used to report a query that is invalid for the time series.
Notes
An example invalid query is one where the anchor is a sequence number
beyond the end of the time series (for example, it is specified using
RangeQuery.from_(anchor: StrictNonNegativeInt)
with a sequence number greater than the latest sequence number, or
RangeQuery.from_last(offset: StrictNonNegativeInt)
with a count
greater than the number of events in the time series),
and the span is a relative time. Since no timestamp is associated
with the anchor, the range is meaningless.
Added in version 6.9.
SessionClosedError ¶
Bases: SessionError
The exception indicating a ISession closure.
Notes
No further operations are possible when this exception has been thrown.
Added in 6.9
SessionSecurityError ¶
Bases: SessionError
The exception indicating that a ISession operation failed due to a security constraint.
Notes
Repeating the operation with the same security credentials is likely to fail.
Added in 6.9
FatalConnectionError ¶
Bases: ProtocolError
The exception indicating a connection has been rejected and should not be retried.
Notes
This exception is never thrown directly but might be the cause of a SessionError
Added in 6.9
AuthenticationError ¶
Bases: FatalConnectionError
The connection exception representing an authentication failure.
Notes
This exception is never thrown directly but might be the cause of a SessionError
Added in 6.9
ProxyAuthenticationError ¶
Bases: ProtocolError
The exception indicating that there was a problem during authentication with a proxy server.
Notes
This exception is never thrown directly but might be the cause of a SessionError
Added in 6.9.