mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-01-25 23:06:04 -05:00
config: Make the batch size for room history fetching configurable.
This commit is contained in:
parent
0940b67eb8
commit
f5ffd69a79
@ -72,7 +72,10 @@ A configuration option to decide if
|
|||||||
should fetch the history for
|
should fetch the history for
|
||||||
unencrytped rooms as well as for encrypted ones. If True, only the history for
|
unencrytped rooms as well as for encrypted ones. If True, only the history for
|
||||||
encrypted rooms is fetched and indexed. Search requests for non-encrypted
|
encrypted rooms is fetched and indexed. Search requests for non-encrypted
|
||||||
rooms are forwarded to the Homeserver.
|
rooms are forwarded to the Homeserver. Defaults to "True".
|
||||||
|
.It Cm IndexingBatchSize
|
||||||
|
The number of messages that should be requested from the Homeserver when we
|
||||||
|
fetch and index messages from the room history. Defaults to 100.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Aditional to the homeserver section a special section with the name
|
Aditional to the homeserver section a special section with the name
|
||||||
|
@ -237,9 +237,11 @@ class PanClient(AsyncClient):
|
|||||||
logger.debug("Fetching room history for {}".format(
|
logger.debug("Fetching room history for {}".format(
|
||||||
room.display_name
|
room.display_name
|
||||||
))
|
))
|
||||||
response = await self.room_messages(fetch_task.room_id,
|
response = await self.room_messages(
|
||||||
fetch_task.token,
|
fetch_task.room_id,
|
||||||
limit=100)
|
fetch_task.token,
|
||||||
|
limit=self.pan_conf.indexing_batch_size
|
||||||
|
)
|
||||||
except ClientConnectionError:
|
except ClientConnectionError:
|
||||||
self.history_fetch_queue.put(fetch_task)
|
self.history_fetch_queue.put(fetch_task)
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ class PanConfigParser(configparser.ConfigParser):
|
|||||||
"UseKeyring": "yes",
|
"UseKeyring": "yes",
|
||||||
"SearchRequests": "off",
|
"SearchRequests": "off",
|
||||||
"IndexEncryptedOnly": "True",
|
"IndexEncryptedOnly": "True",
|
||||||
|
"IndexingBatchSize": "100",
|
||||||
},
|
},
|
||||||
converters={
|
converters={
|
||||||
"address": parse_address,
|
"address": parse_address,
|
||||||
@ -104,6 +105,17 @@ class ServerConfig:
|
|||||||
homeserver.
|
homeserver.
|
||||||
ssl (bool): Enable or disable SSL for the connection between
|
ssl (bool): Enable or disable SSL for the connection between
|
||||||
pantalaimon and the homeserver.
|
pantalaimon and the homeserver.
|
||||||
|
ignore_verification (bool): Enable or disable device verification for
|
||||||
|
E2E encrypted messages.
|
||||||
|
keyring (bool): Enable or disable the OS keyring for the storage of
|
||||||
|
access tokens.
|
||||||
|
search_requests (bool): Enable or disable aditional Homeserver requests
|
||||||
|
for the search API endpoint.
|
||||||
|
index_encrypted_only (bool): Enable or disable message indexing fro
|
||||||
|
non-encrypted rooms.
|
||||||
|
indexing_batch_size (int): The number of messages that should be
|
||||||
|
requested from the Homeserver when we fetch and index messages from
|
||||||
|
the room history.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = attr.ib(type=str)
|
name = attr.ib(type=str)
|
||||||
@ -116,6 +128,7 @@ class ServerConfig:
|
|||||||
keyring = attr.ib(type=bool, default=True)
|
keyring = attr.ib(type=bool, default=True)
|
||||||
search_requests = attr.ib(type=bool, default=False)
|
search_requests = attr.ib(type=bool, default=False)
|
||||||
index_encrypted_only = attr.ib(type=bool, default=True)
|
index_encrypted_only = attr.ib(type=bool, default=True)
|
||||||
|
indexing_batch_size = attr.ib(type=int, default=100)
|
||||||
|
|
||||||
|
|
||||||
@attr.s
|
@attr.s
|
||||||
@ -175,6 +188,13 @@ class PanConfig:
|
|||||||
search_requests = section.getboolean("SearchRequests")
|
search_requests = section.getboolean("SearchRequests")
|
||||||
index_encrypted_only = section.getboolean("IndexEncryptedOnly")
|
index_encrypted_only = section.getboolean("IndexEncryptedOnly")
|
||||||
|
|
||||||
|
indexing_batch_size = section.getint("IndexingBatchSize")
|
||||||
|
|
||||||
|
if not 1 < indexing_batch_size <= 1000:
|
||||||
|
raise PanConfigError("The indexing batch size needs to be "
|
||||||
|
"a positive integer between 1 and "
|
||||||
|
"1000")
|
||||||
|
|
||||||
listen_tuple = (listen_address, listen_port)
|
listen_tuple = (listen_address, listen_port)
|
||||||
|
|
||||||
if listen_tuple in listen_set:
|
if listen_tuple in listen_set:
|
||||||
@ -193,7 +213,8 @@ class PanConfig:
|
|||||||
ignore_verification,
|
ignore_verification,
|
||||||
keyring,
|
keyring,
|
||||||
search_requests,
|
search_requests,
|
||||||
index_encrypted_only
|
index_encrypted_only,
|
||||||
|
indexing_batch_size
|
||||||
)
|
)
|
||||||
|
|
||||||
self.servers[section_name] = server_conf
|
self.servers[section_name] = server_conf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user