Fork me on GitHub

@grzegorzrynkowski_clo At first I was going to suggest getting rid of the as-> threader, but after looking at it, I think the following is most straightforward:

(let [b (ServerBuilder/forPort port)]
  (doseq [h handlers]
    (.addService b h))
  (.start (.build b)))


In general, I prefer using side-effecty constructs for side-effecty operations.

👍 1
Greg Rynkowski21:02:14

make sense, thanks


For example, doseq for adding services to a mutable object.


If you wanna keep the startup msg, I would do:


(let [b (ServerBuilder/forPort port)
      srvr (do (doseq [h handlers]
                 (.addService b h))
               (.start (.build b)))]
  (println "gRPC server started listening on port" port)


One thing I've found useful to build into functions like these is a promise that is delivered once the service has started. It can either be passed in by the caller, or returned as part of a map that wraps the server object. This makes it possible for tests to use it to ensure the service is ready for requests before the test starts hitting it.

👍 1

Anyone has an experience with Multi-part uploads with Amazonica ? Context: I am trying the merge 30K+ files into a single file in a Lambda function.


Why does transit-cljs allow you to read/write directly from/to strings, but transit-clj require the construction of ByteArrayInputStream/`ByteArrayOutputStream`? Is there a way to read and write strings directly in the Clojure version?


@dts.siedel because String is the right abstraction in a js runtime, but not in the java runtime. It's simple to call the String constructor on a byte-array, but you end up doing a bunch of pointless work in common use cases if you convert to string (because often your target isn't a String in memory, it's an output destination like a File or socket which provides and OutputStream to write to directly). Similarly for input, the thing that you get the transit data from will almost always offer an input-stream, getting a String first then translating reduces flexibility and adds pointless layers of work.


That's fair. It just seemed very non-Clojurey to be creating and mutating this odd Java object, but it makes sense in that context. I'll just make a wrapper for my purposes that dumps to an in-memory string.


Thanks for the response @U051SS2EU


yeah - it's very easy to convert a byte-array to string or string to byte-array


I think there's a good comparison to the various collection operations here - it would be trivial to provide a function that scans a collection for a matching key, but it's not provided in order to make using a set or hash-map the low-friction path


(compare to common-lisp or scheme which have sets/hash-maps but many programs use lists instead with O(n) access because it has less friction with a normal coding style)


It makes a lot of sense from that perspective


How to automatically construct spec from data structure?

JIacheng Yang19:02:32

is that even doable for a highly dynamic and flexible thing like spec?


Is there a Markdown parser in Clojure (or Java) than can parse Markdown with GH extensions?


@U4YGF4NGM That's what I'm playing with (via commonmark-hiccup), though it does not seem to be handling tables in my test files even after adding an extension ta parse them.

Braden Shepherdson20:02:01

I'm pondering what best to do with a vanilla java.util.concurrent.Future I'm getting from the Firebase API. trying to .get() it seems to be blocking my REPL thread forever? not sure.

Braden Shepherdson20:02:20

is there a way to wrap it into a Clojure future that will play nicer?


the functions that work on a clojure future also work on that object


realized?, deref (with optional time-out arg), future-cancel

Braden Shepherdson20:02:55

oh, I didn't think I could deref it.


deref will block the same way .get will, except you can optionally provide that time-out arg


I was wrong about realized?, but deref will work> (doto (java.util.concurrent.FutureTask. #(+ 1 1)) (.run))
#object[java.util.concurrent.FutureTask 0x2fa829be "[email protected]"]> (def f *1) 
#'> (realized? f)
ClassCastException java.util.concurrent.FutureTask cannot be cast to clojure.lang.IPending  clojure.core/realized? (core.clj:7453)> @f


Hi, I am trying to use DynamoDB (dockerized local) with I am struggling to override the endpoint to match the local one. I am doing this:

(def db (aws/client {:api :dynamodb :endpoint-override "local" }))
(aws/invoke db {:op :ListTables})
But I get:
=> #:cognitect.anomalies{:category :cognitect.anomalies/not-found, :message "local"}
(meta *1)
{:http-request {:request-method :post,
                :scheme :https,
                :server-port 443,
                :uri "/",
                :headers {"x-amz-date" "20190225T205047Z",
                          "x-amz-target" "DynamoDB_20120810.ListTables",
                          "content-type" "application/x-amz-json-1.0",
                          "host" "local",
                          "authorization" "AWS4-HMAC-SHA256 Credential=AKIAIEJE6SPXIMLB7VRA/20190225/us-east-1/dynamodb/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=2099f67eb5a11b49446bf3cbcf89202d94f3d0cf9973d1d6f5c37e85db202e63"},
                :body "{}",
                :server-name "local"},
 :http-response {:cognitect.anomalies/category :cognitect.anomalies/not-found,
                 :cognitect.anomalies/message "local",
                 :body nil}}


is "local" a placeholder here? I'd expect at least a valid name like "localhost" otherwise


and the credential pointing to something on us-east-1 is suspicious


"dynamodb" : {
        "defaults" : {
          "protocols" : [ "http", "https" ]
        "endpoints" : {
          "local" : {
            "credentialScope" : {
              "region" : "us-east-1"
            "hostname" : "localhost:8000",
            "protocols" : [ "http" ]


I believe this is a known issue