Anonymous avatar Anonymous committed 9668885

Require racket-bert from PLaneT instead of manually installed, rename calls to functions exported from racket-bert. Add README, LICENSE.

Comments (0)

Files changed (8)

+The 2-clause BSD license
+
+Copyright (c) 2011 Yasir M. Arsanukaev <yarsanukaev AT gmail DOT com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright notice, 
+      this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+racket-bertrpc
+==============
+
+A BERT-RPC client library for Racket language.
+
+See the full BERT specification at [bert-rpc.org](http://bert-rpc.org).
+
+This library currentli only supports the following BERT-RPC features:
+
+* `call` request
+* `cast` request
+
+Since this library version depends on BERT serialization library, implemented in R^6RS, you've got to require mutable pairs. See examples section below.
+
+
+Installation
+------------
+
+Require this library in your project:
+
+    (require (planet yasir/racket-bertrpc:1))
+
+
+Examples
+--------
+
+Import the library and create an RPC transport:
+
+    #lang racket
+    (require racket/mpair)
+    (require (prefix-in bertrpc: (planet yasir/racket-bertrpc:1)))
+
+    (define transport (bertrpc:from-uri "bert://192.168.32.40:9999"))
+
+---
+
+Make a call:
+
+    (bertrpc:call transport 'calc 'add (mlist 40 2))
+
+Note that the underlying BERT-RPC transaction of the above call is:
+
+    -> {call, calc, add, [40, 2]}
+    <- {reply, 42}
+    
+In this example, the return value of the `call` is `42`.
+
+---
+
+Make a cast:
+
+    (bertrpc:cast transport 'stats 'incr (mlist))
+
+Note that the underlying BERT-RPC transaction of the above cast is:
+
+    -> {cast, stats, incr, []}
+    <- {noreply}
+    
+The return value of the above `cast` is `'nil` for all successful cast calls. 
+
+
+TODO
+----
+
+* Implement timeouts (probably using vyzo/socket PLaneT library).
+* Implement BERT serialization library in Racket and use it instead of the current, which is R^6RS.
+
+
+Copyright
+---------
+
+Copyright (c) 2011 Yasir M. Arsanukaev. See LICENSE for details.
+
+; Author: Yasir M. Arsanukaev <yarsanukaev AT gmail DOT com>
+; License: The 2-clause BSD license. See LICENSE for details.
+
 #lang racket
 
 (require racket/serialize)
 
-(require bert)
+(require (prefix-in bert: (planet yasir/racket-bert:1)))
 
 (require "errors.ss")
 
     (bertrpc-raise-exn level (cons code message) klass backtrace)))
 
 (define (encode-scheme-request scheme-request)
-  (bert-encode scheme-request))
+  (bert:encode scheme-request))
 
 (define (decode-bert-response bert-response)
-  (let* ((scheme-response (bert-decode bert-response))
+  (let* ((scheme-response (bert:decode bert-response))
          (vect-get-elem (lambda (n) (vector-ref scheme-response n)))
          (resp-kind (vect-get-elem 0)))
     (cond 
        (error-rpc (vect-get-elem 1)))
       (else
        (bertrpc-error "Invalid response received from server.")))))
+
+; Author: Yasir M. Arsanukaev <yarsanukaev AT gmail DOT com>
+; License: The 2-clause BSD license. See LICENSE for details.
+
 #lang racket
 
 (require racket/mpair)
 (define (connection-error host port)
   (let ((msg (format "Unable to connect to ~a:~a.~n" host port)))
     (bertrpc-error connection-exception msg 'nil 'nil)))
+
-#lang setup/infotab
-
-(define name "racket-bertrpc")
-(define blurb
-  '("Implements BERT-RPC client. "
-    "BERT-RPC protocol is described at http://bert-rpc.org"))
-(define primary-file "racket-bertrpc.rkt")
-(define categories '(net))
+#lang setup/infotab
+
+(define name "racket-bertrpc")
+(define homepage "https://bitbucket.org/yasir/racket-bertrpc")
+(define release-notes
+  '())
+(define repositories
+  (list "4.x"))
+(define blurb
+  '((p "Implements " 
+       (a ((href "http://bert-rpc.org")) "BERT-RPC") 
+       " client library.")))
+(define primary-file "racket-bertrpc.rkt")
+(define categories '(net))
+
+#lang racket
+
+(require "racket-bertrpc.rkt")
+(provide (all-from-out "racket-bertrpc.rkt"))
+

racket-bertrpc.rkt

+; Author: Yasir M. Arsanukaev <yarsanukaev AT gmail DOT com>
+; License: The 2-clause BSD license. See LICENSE for details.
+
 #lang racket
 
-(require bert)
-
 (require "encodes.rkt")
 (require "errors.rkt")
 (require "transport.rkt")
 
 ; Sample call
 ; (call (from-uri "bert://192.168.32.40:9999") 'nat 'add (list 5 9))
+
+; Author: Yasir M. Arsanukaev <yarsanukaev AT gmail DOT com>
+; License: The 2-clause BSD license. See LICENSE for details.
+
 #lang racket
 
 (require "errors.ss")
     (else (error "recvt" "Other transports not implemented."))))
 
 (provide from-uri sendt recvt)
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.