Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
dex
pleroma
Commits
52aa65fe
Commit
52aa65fe
authored
7 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Federator Queue: Add seperate in/out queues.
parent
5ff5d583
Branches
fix/mastoapi-attachment-linking
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/pleroma/web/federator/federator.ex
+24
-9
24 additions, 9 deletions
lib/pleroma/web/federator/federator.ex
with
24 additions
and
9 deletions
lib/pleroma/web/federator/federator.ex
+
24
−
9
View file @
52aa65fe
...
...
@@ -14,7 +14,10 @@ defmodule Pleroma.Web.Federator do
Process
.
sleep
(
1000
*
60
*
1
)
# 1 minute
enqueue
(
:refresh_subscriptions
,
nil
)
end
)
GenServer
.
start_link
(
__MODULE__
,
{
:sets
.
new
(),
:queue
.
new
()},
name:
__MODULE__
)
GenServer
.
start_link
(
__MODULE__
,
%{
in
:
{
:sets
.
new
(),
:queue
.
new
()},
out:
{
:sets
.
new
(),
:queue
.
new
()}
},
name:
__MODULE__
)
end
def
handle
(
:refresh_subscriptions
,
_
)
do
...
...
@@ -95,10 +98,18 @@ defmodule Pleroma.Web.Federator do
end
end
def
handle_cast
({
:enqueue
,
type
,
payload
},
{
running_jobs
,
queue
})
do
queue
=
:queue
.
in
({
type
,
payload
},
queue
)
{
running_jobs
,
queue
}
=
maybe_start_job
(
running_jobs
,
queue
)
{
:noreply
,
{
running_jobs
,
queue
}}
def
handle_cast
({
:enqueue
,
type
,
payload
},
state
)
when
type
in
[
:incoming_doc
]
do
%{
in
:
{
i_running_jobs
,
i_queue
},
out:
{
o_running_jobs
,
o_queue
}}
=
state
i_queue
=
:queue
.
in
({
type
,
payload
},
i_queue
)
{
i_running_jobs
,
i_queue
}
=
maybe_start_job
(
i_running_jobs
,
i_queue
)
{
:noreply
,
%{
in
:
{
i_running_jobs
,
i_queue
},
out:
{
o_running_jobs
,
o_queue
}}}
end
def
handle_cast
({
:enqueue
,
type
,
payload
},
state
)
do
%{
in
:
{
i_running_jobs
,
i_queue
},
out:
{
o_running_jobs
,
o_queue
}}
=
state
o_queue
=
:queue
.
in
({
type
,
payload
},
o_queue
)
{
o_running_jobs
,
o_queue
}
=
maybe_start_job
(
o_running_jobs
,
o_queue
)
{
:noreply
,
%{
in
:
{
i_running_jobs
,
i_queue
},
out:
{
o_running_jobs
,
o_queue
}}}
end
def
handle_cast
(
m
,
state
)
do
...
...
@@ -106,9 +117,13 @@ defmodule Pleroma.Web.Federator do
{
:noreply
,
state
}
end
def
handle_info
({
:DOWN
,
ref
,
:process
,
_pid
,
_reason
},
{
running_jobs
,
queue
})
do
running_jobs
=
:sets
.
del_element
(
ref
,
running_jobs
)
{
running_jobs
,
queue
}
=
maybe_start_job
(
running_jobs
,
queue
)
{
:noreply
,
{
running_jobs
,
queue
}}
def
handle_info
({
:DOWN
,
ref
,
:process
,
_pid
,
_reason
},
state
)
do
%{
in
:
{
i_running_jobs
,
i_queue
},
out:
{
o_running_jobs
,
o_queue
}}
=
state
i_running_jobs
=
:sets
.
del_element
(
ref
,
i_running_jobs
)
o_running_jobs
=
:sets
.
del_element
(
ref
,
o_running_jobs
)
{
i_running_jobs
,
i_queue
}
=
maybe_start_job
(
i_running_jobs
,
i_queue
)
{
o_running_jobs
,
o_queue
}
=
maybe_start_job
(
o_running_jobs
,
o_queue
)
{
:noreply
,
%{
in
:
{
i_running_jobs
,
i_queue
},
out:
{
o_running_jobs
,
o_queue
}}}
end
end
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