modules vocab in working order
parent
a7ff4c7884
commit
bc0711cbe5
|
@ -2,4 +2,4 @@ USING: help.syntax help.markup modules.rpc-server modules.using ;
|
||||||
IN: modules.rpc-server
|
IN: modules.rpc-server
|
||||||
HELP: service
|
HELP: service
|
||||||
{ $syntax "IN: my-vocab service" }
|
{ $syntax "IN: my-vocab service" }
|
||||||
{ $description "Allows words defined in the vocabulary to be used as remote procedure calls by " { $link POSTPONE: USING*: } ;
|
{ $description "Allows words defined in the vocabulary to be used as remote procedure calls by " { $link POSTPONE: USING*: } } ;
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs combinators continuations effects
|
USING: accessors assocs combinators continuations effects
|
||||||
io.encodings.binary io.servers.connection kernel namespaces
|
io.encodings.binary io.servers.connection kernel namespaces
|
||||||
sequences serialize sets threads vocabs vocabs.parser init ;
|
sequences serialize sets threads vocabs vocabs.parser init io ;
|
||||||
IN: modules.rpc-server
|
IN: modules.rpc-server
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -11,21 +11,21 @@ SYMBOL: serving-vocabs serving-vocabs [ V{ } clone ] initialize
|
||||||
|
|
||||||
: getter ( -- ) deserialize dup serving-vocabs get-global index
|
: getter ( -- ) deserialize dup serving-vocabs get-global index
|
||||||
[ vocab-words [ stack-effect ] { } assoc-map-as ]
|
[ vocab-words [ stack-effect ] { } assoc-map-as ]
|
||||||
[ \ no-vocab boa ] if serialize ;
|
[ \ no-vocab boa ] if serialize flush ;
|
||||||
|
|
||||||
: doer ( -- ) deserialize dup vocabspec>> serving-vocabs get-global index
|
: doer ( -- ) deserialize dup vocabspec>> serving-vocabs get-global index
|
||||||
[ [ args>> ] [ wordname>> ] [ vocabspec>> vocab-words ] tri at [ execute ] curry with-datastack ]
|
[ [ args>> ] [ wordname>> ] [ vocabspec>> vocab-words ] tri at [ execute ] curry with-datastack ]
|
||||||
[ vocabspec>> \ no-vocab boa ] if serialize ;
|
[ vocabspec>> \ no-vocab boa ] if serialize flush ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
SYNTAX: service current-vocab name>> serving-vocabs get-global adjoin ;
|
SYNTAX: service current-vocab name>> serving-vocabs get-global adjoin ;
|
||||||
|
|
||||||
[ [ binary <threaded-server>
|
[ [ binary <threaded-server>
|
||||||
"rpcs" >>name 9012 >>insecure
|
"rpcs" >>name 9012 >>insecure
|
||||||
[ break deserialize {
|
[ deserialize {
|
||||||
{ [ "getter" ] [ getter ] }
|
{ "getter" [ getter ] }
|
||||||
{ [ "doer" ] [ doer ] }
|
{ "doer" [ doer ] }
|
||||||
{ [ "loader" ] [ deserialize vocab serialize ] }
|
{ "loader" [ deserialize vocab serialize flush ] }
|
||||||
} case ] >>handler
|
} case ] >>handler
|
||||||
start-server ] in-thread drop
|
start-server ] in-thread
|
||||||
] "modules.rpc-server" add-init-hook
|
] "modules.rpc-server" add-init-hook
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs fry generalizations io.encodings.binary
|
USING: accessors assocs fry generalizations io.encodings.binary
|
||||||
io.sockets kernel locals namespaces parser sequences serialize
|
io.sockets kernel locals namespaces parser sequences serialize
|
||||||
vocabs vocabs.parser words tools.continuations io ;
|
vocabs vocabs.parser words io ;
|
||||||
IN: modules.rpc
|
IN: modules.rpc
|
||||||
|
|
||||||
TUPLE: rpc-request args vocabspec wordname ;
|
TUPLE: rpc-request args vocabspec wordname ;
|
||||||
|
@ -13,7 +13,7 @@ TUPLE: rpc-request args vocabspec wordname ;
|
||||||
:: define-remote ( str effect addrspec vocabspec -- )
|
:: define-remote ( str effect addrspec vocabspec -- )
|
||||||
str create-in effect [ in>> length ] [ out>> length ] bi
|
str create-in effect [ in>> length ] [ out>> length ] bi
|
||||||
'[ _ narray vocabspec str rpc-request boa addrspec 9012 <inet> binary
|
'[ _ narray vocabspec str rpc-request boa addrspec 9012 <inet> binary
|
||||||
[ "doer" serialize serialize send-with-check ] with-client _ firstn ]
|
[ "doer" serialize send-with-check ] with-client _ firstn ]
|
||||||
effect define-declared ;
|
effect define-declared ;
|
||||||
|
|
||||||
:: remote-vocab ( addrspec vocabspec -- vocab )
|
:: remote-vocab ( addrspec vocabspec -- vocab )
|
||||||
|
|
Loading…
Reference in New Issue