plaidev / bolt-rpc Goto Github PK
View Code? Open in Web Editor NEW:zap: super fast rpc module which can be extended by middlewares like express.js
Home Page: http://plaidev.github.io/bolt-rpc/
:zap: super fast rpc module which can be extended by middlewares like express.js
Home Page: http://plaidev.github.io/bolt-rpc/
track のキャンセル機能がほしいです
shared track cursor対応。
キャッシュの管理として考えた場合に、インクリメントされるidがあると便利
単体の問い合わせ処理を連続して行うと、処理完了が前後する可能性があります。
現在、cursor.update()を行うと、そのつど毎回問い合わせが発生しますが、問い合わせ完了まで次の問い合わせを行わないようにすることで、処理の前後を安定させた状態でtrackが可能になります。
連続して呼び出すRead OnlyのAPIはtrack/cursorを基本とし、問い合わせ条件変更にupdateを使うことで、動作は安定します。
track_path or @track_path or method
なので、track_path=false
の場合にmethodが入ってしまう。
track_path ? @track_path ? method
であるべき。
サーバのreplaceで一時切断された場合などが想定される、再度methodがコールされるべき。
socket.ioが再接続を行なった場合に、track状態が解除されてしまう。
再接続のイベントを拾って、再track状態に復帰する。
フロントからのクエリを、そのまま登録メソッドにバインドする作りだが、マルチスレッドでの動作が不自由。
socketの段階ではメッセージベースでやりとりしているので、子プロセスに処理を分散する中間層を入れることはできるのではないか。
サーバ側からtrackがかかった時に、APIの再実行を行うか否か判定するメソッドを登録できるようにする
server.pre (req, res, next) ->
start = #
req.end () ->
end = #
next()
dataはupdateされる可能性があるので、cursor作成時に紐付けるoptionsを追加する。
authに使う
1.4.xとして大きめの修正が入っているので、npmの方もアップデートしたい..
expressのuseに似せているが、挙動が直感的でない部分が多いので、修正する
app.use 'module_name', subApp
が自然に動くようにするtrack_path: '<key>.module.method'
とすると、<key>
がroomres.track()
出来るようにするapp.use {track: true}, (req, res) ->
はexpress的な挙動で実装できてないres.track()
を明示的に呼ぶ方法に切り替え。middlewareでreq.end -> res.track()
のようなこともできる同じcursorに連続して(callbackが帰る前に)クエリが投げられた場合、2つめをキャンセルする
throttle系の処理や、別途cache機構を保つ場合などに対応する
refs https://github.com/plaidev/karte-io/issues/8558
sub namespaceをroomとして扱うように変更します。
https://github.com/expressjs/express/blob/master/test/app.use.js
param周りの処理はほぼ不要に思うので、その辺りをどうするか?
Line 182 in 408a0d0
サーバサイドでAPIのエラーログを取りたいとき、ハンドリングを行うための手段が用意されていません。
expressの仕様に似せて、下記の設定を行えるようにします。
app = new Server()
app.use 'api_name', (req, res, next) ->
run (err, data) ->
return next err if err
res.json data
app.use (err, req, res, next) ->
console.log err
next()
err.codeとか
const {data} = await client.send(path, query, options);
...
client.send(path, query, {autoCancel: true}, (err, data) => {
// if same path request is already called until this async callback.
assert(err.message == 'AutoCancelled');
});
元々のコールバックAPI
client.send 'add', {a: 1, b: 2}, (err, val) ->
assert not err
assert val is 3
PromiseライクAPI
cursor = client.send 'add', {a: 1, b: 2}
assert cursor.val is null # 初期値はnull
cursor.end (val) ->
# cursor.on 'end', (val) -> と同じ
assert val is 3
assert cursor.val is val
cursor.error (err) ->
# cursor.on 'error', (err) -> と同じ
# エラーがあればここを通る
assert cursor.err is err
updateができる
cursor.update({a: 2, b: 3})
cursor.end (val) ->
assert val is 5
middleware
# {a: 1, b: 2} -> val = 3 のとき
cursor.map (val) ->
return val * 2
cursor.map (val) ->
return val - 1
cursor.end (val) ->
assert val is 5
https://github.com/component/emitter
var vm = new Vue({
el: '#content',
data: {
lists: todo.get('find', {})
}
})
track
ではなくget
というvue向けに単純なオブジェクトのみを返すAPIを作りました.
理由はこちら : http://tech.nitoyon.com/ja/blog/2014/06/30/vue-js-hook/
# client = Client(xxx, xxx)
cur = client.track 'apiName' # here
cur.error (err) ->
console.log err
widget = Vue.extend
data:
conditions: {}
watch:
conditions: ->
cur.update @conditions
compiled: ->
cur.end (data) ->
# update widget view.
view = Vue.extend
compiled: ->
cur.end (data) ->
# update view.
callbackにクエリパラメータを返してチェックできるようにする
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.