@qingfu/core-env 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/helper.js +3 -4
- package/lib/queue.js +3 -4
- package/package.json +3 -3
package/lib/helper.js
CHANGED
|
@@ -97,10 +97,9 @@ helper.parseLike = ( ...fields ) => {
|
|
|
97
97
|
|
|
98
98
|
helper.ip2geo = async ( ctx, next ) => {
|
|
99
99
|
try {
|
|
100
|
-
let
|
|
101
|
-
let
|
|
102
|
-
|
|
103
|
-
if ( brokers( 'qfu' ) && userID && geo ) await brokers( 'qfu' ).call( 'user.refreshGEO', { userID, ip, agent, ...geo });
|
|
100
|
+
let user = ctx.state.user, ip = ctx.ip, agent = ctx.get( 'User-Agent' );
|
|
101
|
+
let geo = ctx.state.geo = brokers( 'core' ) && await brokers( 'core' ).call( 'detect.geo', { ip });
|
|
102
|
+
if ( brokers( 'qfu' ) && user && geo ) await brokers( 'qfu' ).call( 'user.refreshGEO', { user, ip, agent, ...geo });
|
|
104
103
|
} catch ( err ) {
|
|
105
104
|
( global.logger || global.console ).warn( err );
|
|
106
105
|
}
|
package/lib/queue.js
CHANGED
|
@@ -28,13 +28,12 @@ if ( process.env.QUEUE_URI ) {
|
|
|
28
28
|
|
|
29
29
|
if ( process.env.BULLMQ_URI ) {
|
|
30
30
|
|
|
31
|
-
const { parseURL } = require( 'ioredis/built/utils' );
|
|
32
31
|
const { Queue, Worker } = require( 'bullmq' );
|
|
33
32
|
const queues = [], workers = [], flows = [];
|
|
34
33
|
const DEFAULT_PREFIX = 'bullmq', DEFAULT_NAME = 'default name';
|
|
35
34
|
|
|
36
35
|
global.BullQueue = _.memoize(( name, options ) => {
|
|
37
|
-
let connection =
|
|
36
|
+
let connection = { url: process.env.BULLMQ_URI };
|
|
38
37
|
let queue = new Queue( name, { connection, prefix: DEFAULT_PREFIX, ...options });
|
|
39
38
|
queue.add = _.wrap( queue.add, function( func, ...args ) {
|
|
40
39
|
if ( !_.isString( args[ 0 ])) args = [ DEFAULT_NAME, ...args ];
|
|
@@ -59,7 +58,7 @@ if ( process.env.BULLMQ_URI ) {
|
|
|
59
58
|
});
|
|
60
59
|
|
|
61
60
|
global.BullWorker = ( name, func, options ) => {
|
|
62
|
-
let connection =
|
|
61
|
+
let connection = { url: process.env.BULLMQ_URI };
|
|
63
62
|
let defaults = { removeOnComplete: { count: 0 }, removeOnFail: { count: 0 }};
|
|
64
63
|
let worker = new Worker( name, func, { connection, prefix: DEFAULT_PREFIX, ...defaults, ...options });
|
|
65
64
|
worker.on( 'error', err => {
|
|
@@ -77,7 +76,7 @@ if ( process.env.BULLMQ_URI ) {
|
|
|
77
76
|
};
|
|
78
77
|
|
|
79
78
|
global.BullFlow = options => {
|
|
80
|
-
let connection =
|
|
79
|
+
let connection = { url: process.env.BULLMQ_URI };
|
|
81
80
|
let flow = new FlowProducer({ connection, prefix: DEFAULT_PREFIX, ...options });
|
|
82
81
|
flow.close = _.wrap( flow.close, function( func, ...args ) {
|
|
83
82
|
_.pull( flows, this );
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qingfu/core-env",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"readmeFilename": "README.md",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@koa/cors": "5.0.0",
|
|
7
|
-
"@koa/router": "13.
|
|
7
|
+
"@koa/router": "13.1.0",
|
|
8
8
|
"base-x": "5.0.0",
|
|
9
9
|
"bull": "4.16.3",
|
|
10
|
-
"bullmq": "5.
|
|
10
|
+
"bullmq": "5.13.1",
|
|
11
11
|
"busboy": "1.6.0",
|
|
12
12
|
"cookie": "0.6.0",
|
|
13
13
|
"dotenv-extended": "2.9.0",
|