Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
b6c4b851
Unverified
Commit
b6c4b851
authored
7 years ago
by
Erik Johnston
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2947 from matrix-org/erikj/split_directory_store
Split Directory store
parents
d032785a
69ce365b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/replication/slave/storage/directory.py
+3
-5
3 additions, 5 deletions
synapse/replication/slave/storage/directory.py
synapse/storage/directory.py
+27
-23
27 additions, 23 deletions
synapse/storage/directory.py
with
30 additions
and
28 deletions
synapse/replication/slave/storage/directory.py
+
3
−
5
View file @
b6c4b851
...
...
@@ -14,10 +14,8 @@
# limitations under the License.
from
._base
import
BaseSlavedStore
from
synapse.storage.directory
import
DirectoryStore
from
synapse.storage.directory
import
Directory
Worker
Store
class
DirectoryStore
(
BaseSlavedStore
):
get_aliases_for_room
=
DirectoryStore
.
__dict__
[
"
get_aliases_for_room
"
]
class
DirectoryStore
(
DirectoryWorkerStore
,
BaseSlavedStore
):
pass
This diff is collapsed.
Click to expand it.
synapse/storage/directory.py
+
27
−
23
View file @
b6c4b851
...
...
@@ -29,8 +29,7 @@ RoomAliasMapping = namedtuple(
)
class
DirectoryStore
(
SQLBaseStore
):
class
DirectoryWorkerStore
(
SQLBaseStore
):
@defer.inlineCallbacks
def
get_association_from_room_alias
(
self
,
room_alias
):
"""
Get
'
s the room_id and server list for a given room_alias
...
...
@@ -69,6 +68,28 @@ class DirectoryStore(SQLBaseStore):
RoomAliasMapping
(
room_id
,
room_alias
.
to_string
(),
servers
)
)
def
get_room_alias_creator
(
self
,
room_alias
):
return
self
.
_simple_select_one_onecol
(
table
=
"
room_aliases
"
,
keyvalues
=
{
"
room_alias
"
:
room_alias
,
},
retcol
=
"
creator
"
,
desc
=
"
get_room_alias_creator
"
,
allow_none
=
True
)
@cached
(
max_entries
=
5000
)
def
get_aliases_for_room
(
self
,
room_id
):
return
self
.
_simple_select_onecol
(
"
room_aliases
"
,
{
"
room_id
"
:
room_id
},
"
room_alias
"
,
desc
=
"
get_aliases_for_room
"
,
)
class
DirectoryStore
(
DirectoryWorkerStore
):
@defer.inlineCallbacks
def
create_room_alias_association
(
self
,
room_alias
,
room_id
,
servers
,
creator
=
None
):
"""
Creates an associatin between a room alias and room_id/servers
...
...
@@ -116,17 +137,6 @@ class DirectoryStore(SQLBaseStore):
)
defer
.
returnValue
(
ret
)
def
get_room_alias_creator
(
self
,
room_alias
):
return
self
.
_simple_select_one_onecol
(
table
=
"
room_aliases
"
,
keyvalues
=
{
"
room_alias
"
:
room_alias
,
},
retcol
=
"
creator
"
,
desc
=
"
get_room_alias_creator
"
,
allow_none
=
True
)
@defer.inlineCallbacks
def
delete_room_alias
(
self
,
room_alias
):
room_id
=
yield
self
.
runInteraction
(
...
...
@@ -135,7 +145,6 @@ class DirectoryStore(SQLBaseStore):
room_alias
,
)
self
.
get_aliases_for_room
.
invalidate
((
room_id
,))
defer
.
returnValue
(
room_id
)
def
_delete_room_alias_txn
(
self
,
txn
,
room_alias
):
...
...
@@ -160,17 +169,12 @@ class DirectoryStore(SQLBaseStore):
(
room_alias
.
to_string
(),)
)
return
room_id
@cached
(
max_entries
=
5000
)
def
get_aliases_for_room
(
self
,
room_id
):
return
self
.
_simple_select_onecol
(
"
room_aliases
"
,
{
"
room_id
"
:
room_id
},
"
room_alias
"
,
desc
=
"
get_aliases_for_room
"
,
self
.
_invalidate_cache_and_stream
(
txn
,
self
.
get_aliases_for_room
,
(
room_id
,)
)
return
room_id
def
update_aliases_for_room
(
self
,
old_room_id
,
new_room_id
,
creator
):
def
_update_aliases_for_room_txn
(
txn
):
sql
=
"
UPDATE room_aliases SET room_id = ?, creator = ? WHERE room_id = ?
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment