@@ -833,8 +833,22 @@ def is_locked(self) -> bool:
833
833
834
834
835
835
class Options :
836
+ """
837
+ Supported :func:`coherence.client.Session` options.
838
+ """
839
+
836
840
ENV_SERVER_ADDRESS = "COHERENCE_SERVER_ADDRESS"
841
+ """
842
+ Environment variable to specify the Coherence gRPC server address for the client to connect to. The
843
+ environment variable is used if address is not passed as an argument in the constructor. If the environment
844
+ variable is not set and address is not passed as an argument then `DEFAULT_ADDRESS` is used
845
+ """
837
846
ENV_REQUEST_TIMEOUT = "COHERENCE_CLIENT_REQUEST_TIMEOUT"
847
+ """
848
+ Environment variable to specify the request timeout for each remote call. The environment variable is used if
849
+ request timeout is not passed as an argument in the constructor. If the environment variable is not set and
850
+ request timeout is not passed as an argument then `DEFAULT_REQUEST_TIMEOUT` of 30 seconds is used
851
+ """
838
852
839
853
DEFAULT_ADDRESS : Final [str ] = "localhost:1408"
840
854
"""The default target address to connect to Coherence gRPC server."""
@@ -854,6 +868,23 @@ def __init__(
854
868
channel_options : Optional [Sequence [Tuple [str , Any ]]] = None ,
855
869
tls_options : Optional [TlsOptions ] = None ,
856
870
) -> None :
871
+ """
872
+ Construct a new :func:`coherence.client.Options`
873
+
874
+ :param address: Address of the target Coherence cluster. If not explicitly set, this defaults
875
+ to :func:`coherence.client.Options.DEFAULT_ADDRESS`. See
876
+ also :func:`coherence.client.Options.ENV_SERVER_ADDRESS`
877
+ :param scope: scope name used to link this :func:`coherence.client.Options` to the
878
+ corresponding `ConfigurableCacheFactory` on the server.
879
+ :param request_timeout_seconds: Defines the request timeout, in `seconds`, that will be applied to each
880
+ remote call. If not explicitly set, this defaults to :func:`coherence.client.Options.DEFAULT_REQUEST_TIMEOUT`.
881
+ See also See also :func:`coherence.client.Options.ENV_REQUEST_TIMEOUT`
882
+ :param ser_format: The serialization format. Currently, this is always `json`
883
+ :param channel_options: The `gRPC` `ChannelOptions`. See
884
+ https://grpc.github.io/grpc/python/glossary.html#term-channel_arguments and
885
+ https://github.com/grpc/grpc/blob/master/include/grpc/impl/grpc_types.h
886
+ :param tls_options: Optional TLS configuration.
887
+ """
857
888
addr = os .getenv (Options .ENV_SERVER_ADDRESS )
858
889
if addr is not None :
859
890
self ._address = addr
@@ -882,34 +913,77 @@ def __init__(
882
913
883
914
@property
884
915
def tls_options (self ) -> Optional [TlsOptions ]:
916
+ """
917
+ Returns the TLS-specific configuration options.
918
+
919
+ :return: the TLS-specific configuration options.
920
+ """
885
921
return getattr (self , "_tls_options" , None )
886
922
887
923
@tls_options .setter
888
924
def tls_options (self , tls_options : TlsOptions ) -> None :
925
+ """
926
+ Sets the TLS-specific configuration options.
927
+
928
+ :param tls_options: the TLS-specific configuration options.
929
+ """
889
930
self ._tls_options = tls_options
890
931
891
932
@property
892
933
def address (self ) -> str :
934
+ """
935
+ Return the IPv4 host address and port in the format of ``[host]:[port]``.
936
+
937
+ :return: the IPv4 host address and port in the format of ``[host]:[port]``.
938
+ """
893
939
return self ._address
894
940
895
941
@property
896
942
def scope (self ) -> str :
943
+ """
944
+ Return the scope name used to link this `Session` with to the corresponding `ConfigurableCacheFactory` on the
945
+ server.
946
+
947
+ :return: the scope name used to link this `Session` with to the corresponding `ConfigurableCacheFactory` on the
948
+ server.
949
+ """
897
950
return self ._scope
898
951
899
952
@property
900
953
def format (self ) -> str :
954
+ """
955
+ The serialization format used by this session. This library currently supports JSON serialization only,
956
+ thus this always returns 'json'.
957
+
958
+ :return: the serialization format used by this session.
959
+ """
901
960
return self ._ser_format
902
961
903
962
@property
904
963
def request_timeout_seconds (self ) -> float :
964
+ """
965
+ Returns the request timeout in `seconds`
966
+
967
+ :return: the request timeout in `seconds`
968
+ """
905
969
return self ._request_timeout_seconds
906
970
907
971
@property
908
972
def channel_options (self ) -> Optional [Sequence [Tuple [str , Any ]]]:
973
+ """
974
+ Return the `gRPC` `ChannelOptions`.
975
+
976
+ :return: the `gRPC` `ChannelOptions`.
977
+ """
909
978
return getattr (self , "_channel_options" , None )
910
979
911
980
@channel_options .setter
912
981
def channel_options (self , channel_options : Sequence [Tuple [str , Any ]]) -> None :
982
+ """
983
+ Set the `gRPC` `ChannelOptions`.
984
+
985
+ :param channel_options: the `gRPC` `ChannelOptions`.
986
+ """
913
987
self ._channel_options = channel_options
914
988
915
989
@@ -957,8 +1031,9 @@ class Session:
957
1031
958
1032
def __init__ (self , session_options : Optional [Options ] = None ):
959
1033
"""
1034
+ Construct a new `Session` based on the provided :func:`coherence.client.Options`
960
1035
961
- :param session_options:
1036
+ :param session_options: the provided :func:`coherence.client.Options`
962
1037
"""
963
1038
self ._closed : bool = False
964
1039
self ._caches : dict [str , NamedCache [Any , Any ]] = dict ()
@@ -1028,51 +1103,60 @@ def on(
1028
1103
@property
1029
1104
def channel (self ) -> grpc .aio .Channel :
1030
1105
"""
1106
+ Return the underlying `gRPC` Channel used by this session.
1031
1107
1032
- :return:
1108
+ :return: the underlying `gRPC` Channel used by this session.
1033
1109
"""
1034
1110
return self ._channel
1035
1111
1036
1112
@property
1037
1113
def scope (self ) -> str :
1038
1114
"""
1115
+ Return the scope name used to link this `Session` with to the corresponding `ConfigurableCacheFactory` on the
1116
+ server.
1039
1117
1040
- :return:
1118
+ :return: the scope name used to link this `Session` with to the corresponding `ConfigurableCacheFactory` on the
1119
+ server.
1041
1120
"""
1042
1121
return self ._session_options .scope
1043
1122
1044
1123
@property
1045
1124
def format (self ) -> str :
1046
1125
"""
1126
+ Returns the default serialization format used by the `Session`
1047
1127
1048
- :return:
1128
+ :return: the default serialization format used by the `Session`
1049
1129
"""
1050
1130
return self ._session_options .format
1051
1131
1052
1132
@property
1053
1133
def options (self ) -> Options :
1054
1134
"""
1135
+ Return the :func:`coherence.client.Options` (read-only) used to configure this session.
1055
1136
1056
- :return:
1137
+ :return: the :func:`coherence.client.Options` (read-only) used to configure this session.
1057
1138
"""
1058
1139
return self ._session_options
1059
1140
1060
1141
@property
1061
1142
def closed (self ) -> bool :
1062
1143
"""
1144
+ Returns `True` if Session is closed else `False`
1063
1145
1064
- :return:
1146
+ :return: `True` if Session is closed else `False`
1065
1147
"""
1066
1148
return self ._closed
1067
1149
1068
1150
# noinspection PyProtectedMember
1069
1151
@_pre_call_session
1070
1152
async def get_cache (self , name : str , ser_format : str = DEFAULT_FORMAT ) -> "NamedCache[K, V]" :
1071
1153
"""
1154
+ Returns a :func:`coherence.client.NamedCache` for the specified cache name.
1155
+
1156
+ :param name: the cache name
1157
+ :param ser_format: the serialization format for keys and values stored within the cache
1072
1158
1073
- :param name:
1074
- :param ser_format:
1075
- :return:
1159
+ :return: Returns a :func:`coherence.client.NamedCache` for the specified cache name.
1076
1160
"""
1077
1161
serializer = SerializerRegistry .serializer (ser_format )
1078
1162
c = self ._caches .get (name )
@@ -1086,7 +1170,9 @@ async def get_cache(self, name: str, ser_format: str = DEFAULT_FORMAT) -> "Named
1086
1170
1087
1171
# noinspection PyUnresolvedReferences
1088
1172
async def close (self ) -> None :
1089
- """ """
1173
+ """
1174
+ Close the `Session`
1175
+ """
1090
1176
if not self ._closed :
1091
1177
self ._closed = True
1092
1178
self ._emitter .emit (SessionLifecycleEvent .CLOSED .value )
0 commit comments