Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Dima Krasner
Sharkey
Commits
9835945e
Unverified
Commit
9835945e
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Improve queue option
parent
4f2d5269
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/argv.ts
+2
-0
2 additions, 0 deletions
src/argv.ts
src/queue/index.ts
+28
-12
28 additions, 12 deletions
src/queue/index.ts
src/server/activitypub.ts
+2
-6
2 additions, 6 deletions
src/server/activitypub.ts
with
32 additions
and
18 deletions
src/argv.ts
+
2
−
0
View file @
9835945e
...
...
@@ -5,6 +5,7 @@ program
.
version
(
pkg
.
version
)
.
option
(
'
--no-daemons
'
,
'
Disable daemon processes (for debbuging)
'
)
.
option
(
'
--disable-clustering
'
,
'
Disable clustering
'
)
.
option
(
'
--disable-ap-queue
'
,
'
Disable creating job queue related to ap
'
)
.
option
(
'
--disable-queue
'
,
'
Disable job queue processing
'
)
.
option
(
'
--only-queue
'
,
'
Pocessing job queue only
'
)
.
option
(
'
--quiet
'
,
'
Suppress all logs
'
)
...
...
@@ -13,6 +14,7 @@ program
.
option
(
'
--color
'
,
'
This option is a dummy for some external program
\'
s (e.g. forever) issue.
'
)
.
parse
(
process
.
argv
);
if
(
process
.
env
.
MK_DISABLE_AP_QUEUE
)
program
.
disableApQueue
=
true
;
if
(
process
.
env
.
MK_DISABLE_QUEUE
)
program
.
disableQueue
=
true
;
if
(
process
.
env
.
MK_ONLY_QUEUE
)
program
.
onlyQueue
=
true
;
...
...
This diff is collapsed.
Click to expand it.
src/queue/index.ts
+
28
−
12
View file @
9835945e
import
*
as
Queue
from
'
bee-queue
'
;
import
config
from
'
../config
'
;
import
*
as
httpSignature
from
'
http-signature
'
;
import
config
from
'
../config
'
;
import
{
ILocalUser
}
from
'
../models/user
'
;
import
{
program
}
from
'
../argv
'
;
import
handler
from
'
./processors
'
;
...
...
@@ -31,10 +32,19 @@ function initializeQueue() {
}
}
export
function
createHttpJob
(
data
:
any
)
{
if
(
queueAvailable
)
{
export
function
deliver
(
user
:
ILocalUser
,
content
:
any
,
to
:
any
)
{
if
(
content
==
null
)
return
;
const
data
=
{
type
:
'
deliver
'
,
user
,
content
,
to
};
if
(
queueAvailable
&&
!
program
.
disableApQueue
)
{
return
queue
.
createJob
(
data
)
.
retries
(
3
)
.
retries
(
8
)
.
backoff
(
'
exponential
'
,
1000
)
.
save
();
}
else
{
...
...
@@ -42,15 +52,21 @@ export function createHttpJob(data: any) {
}
}
export
function
deliver
(
user
:
ILocalUser
,
content
:
any
,
to
:
any
)
{
if
(
content
==
null
)
return
;
export
function
processInbox
(
activity
:
any
,
signature
:
httpSignature
.
IParsedSignature
)
{
const
data
=
{
type
:
'
processInbox
'
,
activity
:
activity
,
signature
};
createHttpJob
({
type
:
'
deliver
'
,
user
,
content
,
to
});
if
(
queueAvailable
&&
!
program
.
disableApQueue
)
{
return
queue
.
createJob
(
data
)
.
retries
(
3
)
.
backoff
(
'
exponential
'
,
500
)
.
save
();
}
else
{
return
handler
({
data
},
()
=>
{});
}
}
export
function
createExportNotesJob
(
user
:
ILocalUser
)
{
...
...
This diff is collapsed.
Click to expand it.
src/server/activitypub.ts
+
2
−
6
View file @
9835945e
...
...
@@ -3,7 +3,6 @@ import * as Router from 'koa-router';
import
*
as
json
from
'
koa-json-body
'
;
import
*
as
httpSignature
from
'
http-signature
'
;
import
{
createHttpJob
}
from
'
../queue
'
;
import
{
renderActivity
}
from
'
../remote/activitypub/renderer
'
;
import
Note
from
'
../models/note
'
;
import
User
,
{
isLocalUser
,
ILocalUser
,
IUser
}
from
'
../models/user
'
;
...
...
@@ -17,6 +16,7 @@ import Followers from './activitypub/followers';
import
Following
from
'
./activitypub/following
'
;
import
Featured
from
'
./activitypub/featured
'
;
import
renderQuestion
from
'
../remote/activitypub/renderer/question
'
;
import
{
processInbox
}
from
'
../queue
'
;
// Init router
const
router
=
new
Router
();
...
...
@@ -35,11 +35,7 @@ function inbox(ctx: Router.IRouterContext) {
return
;
}
createHttpJob
({
type
:
'
processInbox
'
,
activity
:
ctx
.
request
.
body
,
signature
});
processInbox
(
ctx
.
request
.
body
,
signature
);
ctx
.
status
=
202
;
}
...
...
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