Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
1de36407
Unverified
Commit
1de36407
authored
4 years ago
by
Erik Johnston
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add `instance_map` config and route replication calls (#7495)
parent
dede23ff
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/7495.feature
+1
-0
1 addition, 0 deletions
changelog.d/7495.feature
synapse/config/workers.py
+17
-0
17 additions, 0 deletions
synapse/config/workers.py
synapse/replication/http/_base.py
+15
-6
15 additions, 6 deletions
synapse/replication/http/_base.py
with
33 additions
and
6 deletions
changelog.d/7495.feature
0 → 100644
+
1
−
0
View file @
1de36407
Add
`instance_map`
config
and
route
replication
calls.
This diff is collapsed.
Click to expand it.
synapse/config/workers.py
+
17
−
0
View file @
1de36407
...
@@ -13,9 +13,20 @@
...
@@ -13,9 +13,20 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
attr
from
._base
import
Config
from
._base
import
Config
@attr.s
class
InstanceLocationConfig
:
"""
The host and port to talk to an instance via HTTP replication.
"""
host
=
attr
.
ib
(
type
=
str
)
port
=
attr
.
ib
(
type
=
int
)
class
WorkerConfig
(
Config
):
class
WorkerConfig
(
Config
):
"""
The workers are processes run separately to the main synapse process.
"""
The workers are processes run separately to the main synapse process.
They have their own pid_file and listener configuration. They use the
They have their own pid_file and listener configuration. They use the
...
@@ -71,6 +82,12 @@ class WorkerConfig(Config):
...
@@ -71,6 +82,12 @@ class WorkerConfig(Config):
elif
not
bind_addresses
:
elif
not
bind_addresses
:
bind_addresses
.
append
(
""
)
bind_addresses
.
append
(
""
)
# A map from instance name to host/port of their HTTP replication endpoint.
instance_map
=
config
.
get
(
"
instance_map
"
,
{})
or
{}
self
.
instance_map
=
{
name
:
InstanceLocationConfig
(
**
c
)
for
name
,
c
in
instance_map
.
items
()
}
def
read_arguments
(
self
,
args
):
def
read_arguments
(
self
,
args
):
# We support a bunch of command line arguments that override options in
# We support a bunch of command line arguments that override options in
# the config. A lot of these options have a worker_* prefix when running
# the config. A lot of these options have a worker_* prefix when running
...
...
This diff is collapsed.
Click to expand it.
synapse/replication/http/_base.py
+
15
−
6
View file @
1de36407
...
@@ -141,17 +141,26 @@ class ReplicationEndpoint(object):
...
@@ -141,17 +141,26 @@ class ReplicationEndpoint(object):
Returns a callable that accepts the same parameters as `_serialize_payload`.
Returns a callable that accepts the same parameters as `_serialize_payload`.
"""
"""
clock
=
hs
.
get_clock
()
clock
=
hs
.
get_clock
()
host
=
hs
.
config
.
worker_replication_host
port
=
hs
.
config
.
worker_replication_http_port
client
=
hs
.
get_simple_http_client
()
client
=
hs
.
get_simple_http_client
()
master_host
=
hs
.
config
.
worker_replication_host
master_port
=
hs
.
config
.
worker_replication_http_port
instance_map
=
hs
.
config
.
worker
.
instance_map
@trace
(
opname
=
"
outgoing_replication_request
"
)
@trace
(
opname
=
"
outgoing_replication_request
"
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
send_request
(
instance_name
=
"
master
"
,
**
kwargs
):
def
send_request
(
instance_name
=
"
master
"
,
**
kwargs
):
# Currently we only support sending requests to master process.
if
instance_name
==
"
master
"
:
if
instance_name
!=
"
master
"
:
host
=
master_host
raise
Exception
(
"
Unknown instance
"
)
port
=
master_port
elif
instance_name
in
instance_map
:
host
=
instance_map
[
instance_name
].
host
port
=
instance_map
[
instance_name
].
port
else
:
raise
Exception
(
"
Instance %r not in
'
instance_map
'
config
"
%
(
instance_name
,)
)
data
=
yield
cls
.
_serialize_payload
(
**
kwargs
)
data
=
yield
cls
.
_serialize_payload
(
**
kwargs
)
...
...
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