Fork me on GitHub
#clojure
<
2018-09-03
>
punit-naik07:09:01

Does anyone know of a good library for API throttling which can handler bursts, limit requests per IP, etc.?

deliciousowl09:09:34

This can handle bursts and limit requests by IP you can add probably add manually: https://github.com/brunoV/throttler

👍 4
punit-naik09:09:01

Thanks but I ended up using diehard (https://github.com/sunng87/diehard) though. throttler current version is running on quite an old version of clojure, so I was facing difficulty incorporating it in my project.

nooga08:09:02

Is there a way to make a new record type that extends existing one?

deliciousowl09:09:05

From what I can tell it's recommended to use multimethods: https://clojure.org/reference/multimethods

deliciousowl09:09:34

but that also sounds suspicously like oop 🙂

🙂 4
Alex Miller (Clojure team)12:09:06

@nooga intentionally, no. per https://clojure.org/reference/datatypes#_datatypes_and_protocols_are_opinionated - the first item there is “concrete derivation is bad”

Alex Miller (Clojure team)12:09:25

which I think states Rich’s opinion on this pretty clearly :)

nooga12:09:01

yeah, I’m asking because I’ve never done it and never intended to

nooga12:09:23

I’m having a component which obviously implements component/Lifecycle let’s say it’s a kafka producer, and I want other components to have that injected as a sink, so that they can call a “method” on it, like (send (:sink myself) some-data).

nooga12:09:00

so that the sender doesn’t care what’s a sink as long as it implements some Sink protocol

nooga12:09:30

thing is, I’d like to have a couple of those kafka producers, each one with different Sink implementation

nooga12:09:57

alternatively I could just put an async channel there and supply a mapping fn when creating those?

nooga12:09:08

don’t know how to approach that

deliciousowl13:09:08

must be some way to do with extend-type or reify, no?

jaihindhreddy17:09:31

@nooga I didn't quite understand your problem, but you might wanna check out #aleph (https://github.com/ztellman/aleph) and manifold(aleph's dependency). You can depend on the stream abstraction instead of a concrete impl like core.async Here's the rationale: http://aleph.io/manifold/rationale.html

nooga17:09:04

yeah, I know aleph, haven’t thought of it though

nooga17:09:17

@coinedtalk that’s what I’m thinking

Karol Wójcik20:09:18

https://stackoverflow.com/questions/22422820/connecting-to-a-headless-nrepl-running-in-a-docker-container-from-another-contai Could someone please explain me why cider-connect on lein repl with host 0.0.0.0 works whereas with host 127.0.0.1 it's not working? How it's possible?

Karol Wójcik20:09:43

I mean in both cases cider tries to connect with localhost

Karol Wójcik20:09:54

so it should work perfectly fine in both cases

lilactown20:09:36

@kwcharllie379 are you asking about docker? or are you having this issue with lein repl outside of a container?

Karol Wójcik20:09:34

I think that I'm asking about docker specifically.

lilactown21:09:53

I’m guessing it has something to do with the way docker maps ports

seancorfield21:09:13

@kwcharllie379 if you start lein repl on host 127.0.0.1, it's only listening on the loopback address which is only accessible within a machine. You need 0.0.0.0 so it listens on all IP addresses assigned to that machine. So you have to use 0.0.0.0 inside Docker for the REPL to be accessible outside Docker.

seancorfield21:09:12

The same is true of starting up lein repl on remote servers in general (and also for when you're programmatically starting nREPL servers inside your apps).

Karol Wójcik21:09:47

Now I got it ;) thank you very much @seancorfield