modules vocab in working order

db4
Sam Anklesaria 2009-08-03 23:12:34 -05:00
parent a7ff4c7884
commit bc0711cbe5
3 changed files with 11 additions and 11 deletions

View File

@ -2,4 +2,4 @@ USING: help.syntax help.markup modules.rpc-server modules.using ;
IN: modules.rpc-server
HELP: 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*: } } ;

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs combinators continuations effects
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
<PRIVATE
@ -11,21 +11,21 @@ SYMBOL: serving-vocabs serving-vocabs [ V{ } clone ] initialize
: getter ( -- ) deserialize dup serving-vocabs get-global index
[ 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
[ [ 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>
SYNTAX: service current-vocab name>> serving-vocabs get-global adjoin ;
[ [ binary <threaded-server>
"rpcs" >>name 9012 >>insecure
[ break deserialize {
{ [ "getter" ] [ getter ] }
{ [ "doer" ] [ doer ] }
{ [ "loader" ] [ deserialize vocab serialize ] }
[ deserialize {
{ "getter" [ getter ] }
{ "doer" [ doer ] }
{ "loader" [ deserialize vocab serialize flush ] }
} case ] >>handler
start-server ] in-thread drop
start-server ] in-thread
] "modules.rpc-server" add-init-hook

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs fry generalizations io.encodings.binary
io.sockets kernel locals namespaces parser sequences serialize
vocabs vocabs.parser words tools.continuations io ;
vocabs vocabs.parser words io ;
IN: modules.rpc
TUPLE: rpc-request args vocabspec wordname ;
@ -13,7 +13,7 @@ TUPLE: rpc-request args vocabspec wordname ;
:: define-remote ( str effect addrspec vocabspec -- )
str create-in effect [ in>> length ] [ out>> length ] bi
'[ _ 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 ;
:: remote-vocab ( addrspec vocabspec -- vocab )