strong-gensym
This commit is contained in:
parent
2ee25068b9
commit
25d3656e09
|
@ -5,7 +5,12 @@
|
|||
(struct-out observe)
|
||||
(struct-out seal)
|
||||
(struct-out inbound)
|
||||
(struct-out outbound))
|
||||
(struct-out outbound)
|
||||
strong-gensym)
|
||||
|
||||
(require (only-in net/base64 base64-encode))
|
||||
(require (only-in racket/random crypto-random-bytes))
|
||||
(require (only-in racket/string string-trim))
|
||||
|
||||
;; Thin veneers over `struct` for declaring intent.
|
||||
(define-syntax-rule (assertion-struct item ...) (struct item ... #:prefab))
|
||||
|
@ -22,3 +27,11 @@
|
|||
|
||||
(struct inbound (assertion) #:prefab)
|
||||
(struct outbound (assertion) #:prefab)
|
||||
|
||||
(define (strong-gensym [head 'g] #:random-bytes [count 16])
|
||||
(string->symbol
|
||||
(format "~a~a"
|
||||
head
|
||||
(string-trim (bytes->string/latin-1
|
||||
(base64-encode (crypto-random-bytes count) #""))
|
||||
#px"=+"))))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(message-struct Says (who what))
|
||||
|
||||
(spawn #:name 'main
|
||||
(field [username (symbol->string (gensym 'chatter))])
|
||||
(field [username (symbol->string (strong-gensym 'chatter-))])
|
||||
|
||||
(define root-facet (current-facet))
|
||||
(define url standard-localhost-broker/tcp)
|
||||
|
|
Loading…
Reference in New Issue