Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
node-bigstream
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bs
node-bigstream
Commits
5f915d6f
Commit
5f915d6f
authored
Jan 31, 2017
by
project
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
6b01852f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
14 deletions
+86
-14
bss_engine.js
storage-service/lib/bss_engine.js
+9
-12
bsspool.js
storage-service/lib/bsspool.js
+20
-0
db.js
storage-service/lib/db.js
+52
-0
storage.js
storage-service/lib/storage.js
+0
-0
playjob.js
test/playjob.js
+3
-0
test.js
test/test.js
+2
-2
No files found.
storage-service/lib/bss_
handler
.js
→
storage-service/lib/bss_
engine
.js
View file @
5f915d6f
...
@@ -6,10 +6,10 @@ var importer = require('./importer');
...
@@ -6,10 +6,10 @@ var importer = require('./importer');
module
.
exports
.
create
=
function
(
prm
)
module
.
exports
.
create
=
function
(
prm
)
{
{
return
new
BSS
Handler
(
prm
);
return
new
BSS
Engine
(
prm
);
}
}
function
BSS
Handler
(
prm
)
function
BSS
Engine
(
prm
)
{
{
if
(
typeof
prm
==
'string'
){
if
(
typeof
prm
==
'string'
){
prm
=
{
'file'
:
prm
};
prm
=
{
'file'
:
prm
};
...
@@ -17,25 +17,22 @@ function BSSHandler(prm)
...
@@ -17,25 +17,22 @@ function BSSHandler(prm)
// this.repos_dir = prm.repos_dir;
// this.repos_dir = prm.repos_dir;
// this.name = prm.name;
// this.name = prm.name;
this
.
file
=
prm
.
file
;
this
.
file
=
prm
.
file
;
this
.
concurrent
=
0
;
}
}
function
name2path
(
n
){
BSSEngine
.
prototype
.
filepath
=
function
()
return
n
.
split
(
'.'
).
join
(
'/'
);
}
BSSHandler
.
prototype
.
filepath
=
function
()
{
{
//return this.repos_dir + '/' + name2path(this.name) + '.bss';
//return this.repos_dir + '/' + name2path(this.name) + '.bss';
return
this
.
file
;
return
this
.
file
;
}
}
BSS
Handler
.
prototype
.
exists
=
function
()
BSS
Engine
.
prototype
.
exists
=
function
()
{
{
var
fp
=
this
.
filepath
();
var
fp
=
this
.
filepath
();
return
fs
.
existsSync
(
fp
);
return
fs
.
existsSync
(
fp
);
}
}
BSS
Handler
.
prototype
.
open
=
function
(
cb
)
BSS
Engine
.
prototype
.
open
=
function
(
cb
)
{
{
var
self
=
this
;
var
self
=
this
;
...
@@ -64,13 +61,13 @@ BSSHandler.prototype.open = function(cb)
...
@@ -64,13 +61,13 @@ BSSHandler.prototype.open = function(cb)
}
}
BSS
Handler
.
prototype
.
close
=
function
(
cb
)
BSS
Engine
.
prototype
.
close
=
function
(
cb
)
{
{
this
.
bss
.
close
(
cb
);
this
.
bss
.
close
(
cb
);
}
}
BSS
Handler
.
prototype
.
cmd
=
function
(
cmd
,
cb
)
BSS
Engine
.
prototype
.
cmd
=
function
(
cmd
,
cb
)
{
{
var
command
=
cmd
.
command
;
var
command
=
cmd
.
command
;
var
param
=
cmd
.
param
;
var
param
=
cmd
.
param
;
...
@@ -84,7 +81,7 @@ BSSHandler.prototype.cmd = function(cmd,cb)
...
@@ -84,7 +81,7 @@ BSSHandler.prototype.cmd = function(cmd,cb)
}
}
}
}
BSS
Handler
.
prototype
.
cmd_write
=
function
(
prm
,
cb
)
BSS
Engine
.
prototype
.
cmd_write
=
function
(
prm
,
cb
)
{
{
var
data
=
prm
.
data
;
var
data
=
prm
.
data
;
var
meta
=
prm
.
meta
;
var
meta
=
prm
.
meta
;
...
...
storage-service/lib/bsspool.js
0 → 100644
View file @
5f915d6f
var
BSSEngine
=
require
(
'./bss_engine'
);
module
.
exports
=
BSSPool
;
function
BSSPool
(
prm
)
{
this
.
repos_dir
=
prm
.
repos_dir
this
.
pool
=
[];
}
BSSPool
.
prototype
.
get
=
function
(
name
,
cb
)
{
var
filepath
=
this
.
repos_dir
+
'/'
+
name2path
(
name
)
+
'.bss'
var
bssname
=
name
;
}
function
name2path
(
name
){
return
name
.
split
(
'.'
).
join
(
'/'
);
}
storage-service/lib/db.js
0 → 100644
View file @
5f915d6f
var
BSSPool
=
require
(
'./bsspool'
);
function
Db
(
cfg
)
{
this
.
repos_dir
=
cfg
.
repos_dir
;
this
.
bsspool
=
new
BSSPool
({
'repos_dir'
:
this
.
repos_dir
});
}
Db
.
prototype
.
request
=
function
(
req
,
cb
)
{
if
(
req
.
object_type
!=
'storage_service_request'
){
return
cb
(
null
,
result_error
(
'invalid request'
));
}
var
cmd
=
req
.
command
;
switch
(
cmd
)
{
case
'write'
:
var
prm_w
=
{
'storage'
:
req
.
storage_name
,
'meta'
:
req
.
meta
,
'data'
:
req
.
resource
.
value
}
this
.
bsscmd_w
(
prm_w
,
cb
)
break
;
default
:
cb
(
null
,
result_error
(
'invalid command'
));
}
}
Db
.
prototype
.
bsscmd_w
=
function
(
cmd
,
cb
)
{
var
filepath
=
this
.
repos_dir
+
'/'
+
name2path
(
cmd
.
storage
)
+
'.bss'
var
bssname
=
cmd
.
storage
;
}
function
name2path
(
name
){
return
name
.
split
(
'.'
).
join
(
'/'
);
}
function
result_error
(
msg
)
{
return
{
'status'
:
'ERR'
,
'msg'
:
msg
}
}
function
result_ok
(
msg
)
{
return
{
'status'
:
'OK'
,
'msg'
:
msg
}
}
storage-service/lib/storage.js
deleted
100644 → 0
View file @
6b01852f
test/playjob.js
View file @
5f915d6f
...
@@ -76,6 +76,7 @@ function run_job(cfg)
...
@@ -76,6 +76,7 @@ function run_job(cfg)
var
dm_i
=
domain
.
create
();
var
dm_i
=
domain
.
create
();
dm_i
.
on
(
'error'
,
function
(
err
)
{
dm_i
.
on
(
'error'
,
function
(
err
)
{
console
.
log
(
'plugins error'
);
console
.
log
(
'plugins error'
);
console
.
log
(
err
);
callback
(
err
)
callback
(
err
)
});
});
...
@@ -98,6 +99,7 @@ function run_job(cfg)
...
@@ -98,6 +99,7 @@ function run_job(cfg)
var
dm_t
=
domain
.
create
();
var
dm_t
=
domain
.
create
();
dm_t
.
on
(
'error'
,
function
(
err
)
{
dm_t
.
on
(
'error'
,
function
(
err
)
{
console
.
log
(
'plugins error'
);
console
.
log
(
'plugins error'
);
console
.
log
(
err
);
callback
(
err
)
callback
(
err
)
});
});
...
@@ -120,6 +122,7 @@ function run_job(cfg)
...
@@ -120,6 +122,7 @@ function run_job(cfg)
var
dm_o
=
domain
.
create
();
var
dm_o
=
domain
.
create
();
dm_o
.
on
(
'error'
,
function
(
err
)
{
dm_o
.
on
(
'error'
,
function
(
err
)
{
console
.
log
(
'plugins error'
);
console
.
log
(
'plugins error'
);
console
.
log
(
err
);
callback
(
err
)
callback
(
err
)
});
});
...
...
test/test.js
View file @
5f915d6f
...
@@ -22,9 +22,9 @@ const crypto = require("crypto");
...
@@ -22,9 +22,9 @@ const crypto = require("crypto");
//
//
// console.log(id);
// console.log(id);
var
bss_handler
=
ctx
.
getLib
(
'storage-service/lib/bss_
handler
'
);
var
bss_handler
=
ctx
.
getLib
(
'storage-service/lib/bss_
engine
'
);
var
bss
=
bss_handler
.
create
(
'd:/testfile/hnd.bss'
);
var
bss
=
bss_handler
.
create
(
'd:/testfile/
new/slash/
hnd.bss'
);
bss
.
open
(
function
(
err
){
bss
.
open
(
function
(
err
){
console
.
log
(
'open'
);
console
.
log
(
'open'
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment