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
1836c0e4
Commit
1836c0e4
authored
Apr 20, 2020
by
Kamron Aroonrua
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bss lazyopen
parent
b02d88d7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
40 deletions
+43
-40
bss_engine.js
storage-service/lib/bss_engine.js
+43
-40
No files found.
storage-service/lib/bss_engine.js
View file @
1836c0e4
...
@@ -10,7 +10,6 @@ var importer = require('./importer');
...
@@ -10,7 +10,6 @@ var importer = require('./importer');
var
dataevent
=
require
(
'./dataevent'
);
var
dataevent
=
require
(
'./dataevent'
);
var
sutils
=
require
(
'./storage-utils'
);
var
sutils
=
require
(
'./storage-utils'
);
var
_self
=
null
;
module
.
exports
.
create
=
function
(
prm
)
module
.
exports
.
create
=
function
(
prm
)
{
{
var
ins
=
prm
;
var
ins
=
prm
;
...
@@ -23,40 +22,29 @@ module.exports.create = function(prm)
...
@@ -23,40 +22,29 @@ module.exports.create = function(prm)
function
BSSEngine
(
prm
)
function
BSSEngine
(
prm
)
{
{
_
self
=
this
;
var
self
=
this
;
if
(
typeof
prm
==
'string'
){
if
(
typeof
prm
==
'string'
){
prm
=
{
'file'
:
prm
,
'context'
:
null
};
prm
=
{
'file'
:
prm
,
'context'
:
null
};
}
}
// this.repos_dir = prm.repos_dir;
// this.name = prm.name;
this
.
file
=
prm
.
file
;
this
.
file
=
prm
.
file
;
this
.
name
=
prm
.
name
;
this
.
name
=
prm
.
name
;
this
.
context
=
(
prm
.
context
)?
prm
.
context
:
null
;
this
.
context
=
(
prm
.
context
)?
prm
.
context
:
null
;
this
.
concurrent
=
0
;
this
.
concurrent
=
0
;
this
.
serial
=
prm
.
serial
||
''
;
this
.
serial
=
prm
.
serial
||
''
;
this
.
outdate
=
false
;
this
.
outdate
=
false
;
}
BSSEngine
.
prototype
.
filepath
=
function
()
{
//return this.repos_dir + '/' + name2path(this.name) + '.bss';
return
this
.
file
;
}
BSSEngine
.
prototype
.
exists
=
function
()
this
.
bss
=
null
;
{
this
.
open
=
thunky
(
openbss
);
var
fp
=
this
.
filepath
();
this
.
open
();
return
fs
.
existsSync
(
fp
);
}
BSSEngine
.
prototype
.
open
=
thunky
(
function
(
cb
)
function
openbss
(
cb
)
{
{
if
(
_self
.
exists
(
))
if
(
fs
.
existsSync
(
self
.
file
))
{
{
open
()
open
()
}
else
{
}
else
{
BinStream
.
format
(
_self
.
filepath
()
,
function
(
err
){
BinStream
.
format
(
self
.
file
,
function
(
err
){
if
(
!
err
){
if
(
!
err
){
open
()
open
()
}
else
{
}
else
{
...
@@ -66,20 +54,34 @@ BSSEngine.prototype.open = thunky(function(cb)
...
@@ -66,20 +54,34 @@ BSSEngine.prototype.open = thunky(function(cb)
}
}
function
open
(){
function
open
(){
BinStream
.
open
(
_self
.
filepath
()
,
function
(
err
,
bss
){
BinStream
.
open
(
self
.
file
,
function
(
err
,
bss
){
if
(
!
err
){
if
(
!
err
){
_
self
.
bss
=
bss
;
self
.
bss
=
bss
;
}
}
cb
(
err
,
bss
);
cb
(
err
,
bss
);
});
});
}
}
});
}
}
BSSEngine
.
prototype
.
filepath
=
function
()
{
return
this
.
file
;
}
BSSEngine
.
prototype
.
exists
=
function
()
{
var
fp
=
this
.
filepath
();
return
fs
.
existsSync
(
fp
);
}
BSSEngine
.
prototype
.
close
=
function
(
cb
)
BSSEngine
.
prototype
.
close
=
function
(
cb
)
{
{
_self
.
open
((
err
,
bss
)
=>
{
var
self
=
this
;
self
.
open
((
err
,
bss
)
=>
{
bss
.
close
(
cb
);
bss
.
close
(
cb
);
});
});
}
}
...
@@ -87,13 +89,13 @@ BSSEngine.prototype.close = function(cb)
...
@@ -87,13 +89,13 @@ BSSEngine.prototype.close = function(cb)
BSSEngine
.
prototype
.
cmd
=
function
(
cmd
,
cb
)
BSSEngine
.
prototype
.
cmd
=
function
(
cmd
,
cb
)
{
{
var
self
=
this
var
command
=
cmd
.
command
;
var
command
=
cmd
.
command
;
var
param
=
cmd
.
param
;
var
param
=
cmd
.
param
;
switch
(
command
)
{
switch
(
command
)
{
case
'write'
:
case
'write'
:
console
.
log
(
'CMD WRITE....'
)
self
.
cmd_write
(
param
,
cb
);
_self
.
cmd_write
(
param
,
cb
);
break
;
break
;
default
:
default
:
cb
(
'invalid cmd'
);
cb
(
'invalid cmd'
);
...
@@ -102,24 +104,25 @@ BSSEngine.prototype.cmd = function(cmd,cb)
...
@@ -102,24 +104,25 @@ BSSEngine.prototype.cmd = function(cmd,cb)
BSSEngine
.
prototype
.
cmd_write
=
function
(
prm
,
cb
)
BSSEngine
.
prototype
.
cmd_write
=
function
(
prm
,
cb
)
{
{
var
self
=
this
;
var
data
=
parseData
(
prm
.
data
);
var
data
=
parseData
(
prm
.
data
);
var
meta
=
prm
.
meta
;
var
meta
=
prm
.
meta
;
if
(
!
data
){
return
cb
(
"null data"
)}
if
(
!
data
){
return
cb
(
"null data"
)}
_
self
.
open
((
err
,
bss
)
=>
{
self
.
open
((
err
,
bss
)
=>
{
bss
.
write
(
data
,{
'meta'
:
meta
},
function
(
err
,
obj
){
bss
.
write
(
data
,{
'meta'
:
meta
},
function
(
err
,
obj
){
if
(
!
err
){
if
(
!
err
){
var
head
=
obj
.
getHeader
();
var
head
=
obj
.
getHeader
();
var
obj_id
=
new
ObjId
(
head
.
ID
);
var
obj_id
=
new
ObjId
(
head
.
ID
);
var
resp
=
{
var
resp
=
{
'resource_id'
:
obj_id
.
toString
(),
'resource_id'
:
obj_id
.
toString
(),
'storage_name'
:
_
self
.
name
'storage_name'
:
self
.
name
}
}
//dataevent.newdata({'resourceId':obj_id.toString(),'storageId':self.name});
//dataevent.newdata({'resourceId':obj_id.toString(),'storageId':self.name});
if
(
_
self
.
context
){
if
(
self
.
context
){
newdata_event
(
_self
.
context
,{
'resourceId'
:
obj_id
.
toString
(),
'storageId'
:
_
self
.
name
});
newdata_event
(
self
.
context
,{
'resourceId'
:
obj_id
.
toString
(),
'storageId'
:
self
.
name
});
}
}
cb
(
null
,
resp
);
cb
(
null
,
resp
);
...
...
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