natsio-sysclient 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,162 @@
1
+ """NATS system/monitoring API client — the `$SYS.REQ.SERVER` endpoints.
2
+
3
+ Port of orbit.go's `natssysclient`. Connect with system-account credentials,
4
+ wrap the client, and ask one server or the whole cluster:
5
+
6
+ import natsio
7
+ from natsio.sysclient import SysClient, ConnzOptions
8
+
9
+ nc = await natsio.connect("nats://localhost:4222", user="sys", password="pw")
10
+ sys = SysClient(nc)
11
+
12
+ # every server that answers within the stall/timeout window
13
+ for varz in await sys.varz_ping():
14
+ print(varz.server.id, varz.data.version, varz.data.connections)
15
+
16
+ # one named server
17
+ health = await sys.healthz(varz.server.id)
18
+ assert health.data.status == "ok"
19
+
20
+ # offset/limit paging, walked for you
21
+ async for page in sys.all_connz(varz.server.id, ConnzOptions(limit=64, auth=True)):
22
+ for conn in page.data.connections:
23
+ print(conn.cid, conn.authorized_user, conn.account)
24
+
25
+ Endpoints: `VARZ`, `CONNZ`, `JSZ`, `HEALTHZ`, `STATSZ`, `SUBSZ` — each with a
26
+ by-id method (`varz`), a cluster-ping method (`varz_ping`), and, where the
27
+ endpoint pages, an async iterator (`all_connz`, `all_subsz`, `all_jsz`).
28
+
29
+ Responses are `JsonModel`s: fields a newer server adds are preserved in `extra`
30
+ instead of being dropped.
31
+ """
32
+
33
+ from natsio.sysclient.client import (
34
+ DEFAULT_REQUEST_TIMEOUT,
35
+ DEFAULT_STALL,
36
+ PING_TARGET,
37
+ SYS_REQ_SERVER_PREFIX,
38
+ Endpoint,
39
+ PagedResponses,
40
+ SysClient,
41
+ SysClientOptions,
42
+ )
43
+ from natsio.sysclient.connz import ConnInfo, Connz, ConnzResponse, TLSPeerCert
44
+ from natsio.sysclient.entities import (
45
+ APIError,
46
+ DataStats,
47
+ JetStreamAPIStats,
48
+ JetStreamConfig,
49
+ JetStreamStats,
50
+ JetStreamVarz,
51
+ MetaClusterInfo,
52
+ PeerInfo,
53
+ ServerInfo,
54
+ SlowConsumersStats,
55
+ SubDetail,
56
+ )
57
+ from natsio.sysclient.errors import (
58
+ InvalidResponseError,
59
+ InvalidServerIDError,
60
+ NoResponsesError,
61
+ PagerStateError,
62
+ SysAPIError,
63
+ SysClientError,
64
+ SysValidationError,
65
+ )
66
+ from natsio.sysclient.healthz import Healthz, HealthzError, HealthzErrorType, HealthzResponse
67
+ from natsio.sysclient.jsz import AccountDetail, JSInfo, JszResponse, RaftGroupDetail, StreamDetail, StreamSourceInfo
68
+ from natsio.sysclient.options import (
69
+ ConnState,
70
+ ConnzOptions,
71
+ EventFilterOptions,
72
+ HealthzOptions,
73
+ JszOptions,
74
+ SortOpt,
75
+ StatszOptions,
76
+ SubszOptions,
77
+ VarzOptions,
78
+ )
79
+ from natsio.sysclient.statsz import GatewayStat, RouteStat, ServerStats, StatszResponse
80
+ from natsio.sysclient.subsz import Subsz, SubszResponse
81
+ from natsio.sysclient.varz import (
82
+ ClusterOptsVarz,
83
+ DenyRules,
84
+ GatewayOptsVarz,
85
+ LeafNodeOptsVarz,
86
+ MQTTOptsVarz,
87
+ OCSPResponseCacheVarz,
88
+ RemoteGatewayOptsVarz,
89
+ RemoteLeafOptsVarz,
90
+ Varz,
91
+ VarzResponse,
92
+ WebsocketOptsVarz,
93
+ )
94
+
95
+ __all__ = [
96
+ "DEFAULT_REQUEST_TIMEOUT",
97
+ "DEFAULT_STALL",
98
+ "PING_TARGET",
99
+ "SYS_REQ_SERVER_PREFIX",
100
+ "APIError",
101
+ "AccountDetail",
102
+ "ClusterOptsVarz",
103
+ "ConnInfo",
104
+ "ConnState",
105
+ "Connz",
106
+ "ConnzOptions",
107
+ "ConnzResponse",
108
+ "DataStats",
109
+ "DenyRules",
110
+ "Endpoint",
111
+ "EventFilterOptions",
112
+ "GatewayOptsVarz",
113
+ "GatewayStat",
114
+ "Healthz",
115
+ "HealthzError",
116
+ "HealthzErrorType",
117
+ "HealthzOptions",
118
+ "HealthzResponse",
119
+ "InvalidResponseError",
120
+ "InvalidServerIDError",
121
+ "JSInfo",
122
+ "JetStreamAPIStats",
123
+ "JetStreamConfig",
124
+ "JetStreamStats",
125
+ "JetStreamVarz",
126
+ "JszOptions",
127
+ "JszResponse",
128
+ "LeafNodeOptsVarz",
129
+ "MQTTOptsVarz",
130
+ "MetaClusterInfo",
131
+ "NoResponsesError",
132
+ "OCSPResponseCacheVarz",
133
+ "PagedResponses",
134
+ "PagerStateError",
135
+ "PeerInfo",
136
+ "RaftGroupDetail",
137
+ "RemoteGatewayOptsVarz",
138
+ "RemoteLeafOptsVarz",
139
+ "RouteStat",
140
+ "ServerInfo",
141
+ "ServerStats",
142
+ "SlowConsumersStats",
143
+ "SortOpt",
144
+ "StatszOptions",
145
+ "StatszResponse",
146
+ "StreamDetail",
147
+ "StreamSourceInfo",
148
+ "SubDetail",
149
+ "Subsz",
150
+ "SubszOptions",
151
+ "SubszResponse",
152
+ "SysAPIError",
153
+ "SysClient",
154
+ "SysClientError",
155
+ "SysClientOptions",
156
+ "SysValidationError",
157
+ "TLSPeerCert",
158
+ "Varz",
159
+ "VarzOptions",
160
+ "VarzResponse",
161
+ "WebsocketOptsVarz",
162
+ ]