ry-pg-utils 1.0.7__py3-none-any.whl → 1.0.9__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.
@@ -3,10 +3,9 @@ from ry_redis_bus.channels import Channel
3
3
  from ry_pg_utils.pb_types.database_pb2 import DatabaseConfigPb # pylint: disable=no-name-in-module
4
4
  from ry_pg_utils.pb_types.database_pb2 import ( # pylint: disable=no-name-in-module
5
5
  DatabaseNotificationPb,
6
- DatabaseSettingsPb,
7
6
  )
8
7
 
9
8
  # Channels
10
9
  DATABASE_CHANNEL = Channel("DATABASE_CHANNEL", DatabaseConfigPb)
11
- DATABASE_CONFIG_CHANNEL = Channel("DATABASE_CONFIG_CHANNEL", DatabaseSettingsPb)
10
+ DATABASE_CONFIG_CHANNEL = Channel("DATABASE_CONFIG_CHANNEL", DatabaseConfigPb)
12
11
  DATABASE_NOTIFY_CHANNEL = Channel("DATABASE_NOTIFY_CHANNEL", DatabaseNotificationPb)
ry_pg_utils/updater.py CHANGED
@@ -11,7 +11,7 @@ from ryutils.verbose import Verbose
11
11
  from ry_pg_utils.connect import close_engine, init_database, is_database_initialized
12
12
  from ry_pg_utils.ipc import channels
13
13
  from ry_pg_utils.pb_types.database_pb2 import ( # pylint: disable=no-name-in-module
14
- DatabaseSettingsPb,
14
+ DatabaseConfigPb,
15
15
  PostgresMessagePb,
16
16
  PostgresPb,
17
17
  )
@@ -21,14 +21,22 @@ DB_RETRY_TIME = 5.0
21
21
 
22
22
 
23
23
  def get_database_settings(
24
- message_pb: DatabaseSettingsPb, backend_id: str, verbose: bool = False
24
+ message_pb: DatabaseConfigPb, backend_id: str, verbose: bool = False
25
25
  ) -> T.Optional[PostgresInfo]:
26
- raw_db_config_pb = message_pb.postgres.get(backend_id, None)
26
+ # Access the nested databaseSettings field
27
+ if not message_pb.HasField("databaseSettings"):
28
+ return None
27
29
 
28
- if raw_db_config_pb is None:
30
+ database_settings = message_pb.databaseSettings
31
+
32
+ # Check if this is the primary database
33
+ if not database_settings.primaryDatabase:
29
34
  return None
30
35
 
31
- if not message_pb.primaryDatabase:
36
+ # Get the postgres config for this backend
37
+ raw_db_config_pb = database_settings.postgres.get(backend_id, None)
38
+
39
+ if raw_db_config_pb is None:
32
40
  return None
33
41
 
34
42
  db_config_pb: PostgresPb = raw_db_config_pb
@@ -84,7 +92,7 @@ class DbUpdater(RedisClientBase):
84
92
  self.logging_error_db_callback = logging_error_db_callback
85
93
 
86
94
  @message_handler
87
- def handle_database_config_message(self, message_pb: DatabaseSettingsPb) -> None:
95
+ def handle_database_config_message(self, message_pb: DatabaseConfigPb) -> None:
88
96
  database_settings = get_database_settings(message_pb, backend_id=self.backend_id)
89
97
 
90
98
  if database_settings is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ry-pg-utils
3
- Version: 1.0.7
3
+ Version: 1.0.9
4
4
  Summary: Utility functions for PostgreSQL
5
5
  Author: Ross Yeager
6
6
  Author-email: ryeager12@email.com
@@ -6,17 +6,17 @@ ry_pg_utils/notify_trigger.py,sha256=_dsuPkoqjnSQqWrsdZK3FqI6zG5UuygVXHwtERwN99Y
6
6
  ry_pg_utils/parse_args.py,sha256=swFYq2-nBggul67C9ibNzsf9goEXDKZkLNSISbJZgOw,751
7
7
  ry_pg_utils/postgres_info.py,sha256=mj9er830jvrJXUFuFKx1EmZMjuEpMDcd901kgYb_Cck,1495
8
8
  ry_pg_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- ry_pg_utils/updater.py,sha256=TbUKJHQarzRrDjcbjbzIhy1sO61o-YhEG594gWnI0LA,5831
9
+ ry_pg_utils/updater.py,sha256=nfOR2hpf83buaJc0oyiHf0xfE1pl51CYOz1PuRid198,6103
10
10
  ry_pg_utils/ipc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- ry_pg_utils/ipc/channels.py,sha256=sjYuRjmqWMN26v8m6Qm72lecwOJ1dZAF-qfcDR-qjsY,525
11
+ ry_pg_utils/ipc/channels.py,sha256=3w88R_BW5wLW7NX4iNAS3akgXo0JFQufdR7y-l_dNGE,499
12
12
  ry_pg_utils/pb_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  ry_pg_utils/pb_types/database_pb2.py,sha256=yf__HycGrVoU8pzhYdnOhXhfAkgjeGl80ls_RsLemy4,2780
14
14
  ry_pg_utils/pb_types/database_pb2.pyi,sha256=svpmlEY_99dA_u3CJqn7CO5D7CH2pAGTOqlhVMZLXC4,5689
15
15
  ry_pg_utils/pb_types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  ry_pg_utils/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  ry_pg_utils/tools/db_query.py,sha256=sQESUB3zxv3h2bKcodfwJHKHGXdSn6BNaBiyZvg6eNY,19557
18
- ry_pg_utils-1.0.7.dist-info/licenses/LICENSE,sha256=PYnig94SABlde939TWrqvOqQkkfjuHttf8KpWKlPFlA,1068
19
- ry_pg_utils-1.0.7.dist-info/METADATA,sha256=-ib-1zWpEBdqneZ2wjbUivhGdv_hAtSJH8IwzE0x4Ns,18039
20
- ry_pg_utils-1.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
- ry_pg_utils-1.0.7.dist-info/top_level.txt,sha256=OruzbmsQHYyPnAw8RichQ5GK1Sxj-MQwWfJ93PEHXIM,12
22
- ry_pg_utils-1.0.7.dist-info/RECORD,,
18
+ ry_pg_utils-1.0.9.dist-info/licenses/LICENSE,sha256=PYnig94SABlde939TWrqvOqQkkfjuHttf8KpWKlPFlA,1068
19
+ ry_pg_utils-1.0.9.dist-info/METADATA,sha256=eHg0wS2vfpifjX9vEntJEPSLJOucwhylSfnMgrdpN-s,18039
20
+ ry_pg_utils-1.0.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
+ ry_pg_utils-1.0.9.dist-info/top_level.txt,sha256=OruzbmsQHYyPnAw8RichQ5GK1Sxj-MQwWfJ93PEHXIM,12
22
+ ry_pg_utils-1.0.9.dist-info/RECORD,,