Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom action without params #31

Open
faxm0dem opened this issue Oct 14, 2024 · 3 comments
Open

Custom action without params #31

faxm0dem opened this issue Oct 14, 2024 · 3 comments

Comments

@faxm0dem
Copy link
Contributor

I tried adding a cusom action without any parameters:

(defn now*
  "Sets the time of events to right now"
  [_ & children]
  (fn stream [event]
    (let [current-time (quot (System/currentTimeMillis) 1000)
          modevent (assoc event :time current-time)]
      (a/call-rescue modevent children))))

When I try to use it with the following stream:

(streams
  (stream {:name :now :default true}
    (custom :now (index [:host :service]))))

I get the following error message:

{\n :cause Key must be integer\n :via\n [{:type java.lang.IllegalArgumentException\n   :message Key must be integer\n   :at [clojure.lang.APersistentVector invoke APersistentVector.java 297]}]\n :trace\n [[clojure.lang.APersistentVector invoke APersistentVector.java 297]\n  [mirabelle.action$call_rescue invokeStatic action.clj 70]\n  [mirabelle.action$call_rescue invoke action.clj 67]\n  [abricot.core$now_STAR_$stream__254 invoke core.clj 51]\n  [mirabelle.action$call_rescue invokeStatic action.clj 70]\n  [mirabelle.action$call_rescue invoke action.clj 67]\n  [mirabelle.action$sdo_STAR_$stream__2325 invoke action.clj 418]\n  [mirabelle.stream$stream_BANG_ invokeStatic stream.clj 118]\n  [mirabelle.stream$stream_BANG_ invoke stream.clj 116]\n  [mirabelle.stream.StreamHandler push_BANG_ stream.clj 265]\n  [mirabelle.transport.tcp$gen_tcp_handler$handler_fn__13617 invoke tcp.clj 48]\n  [clojure.core$run_BANG_$fn__8880 invoke core.clj 7783]\n  [clojure.lang.ArrayChunk reduce ArrayChunk.java 58]\n  [clojure.core.protocols$fn__8244 invokeStatic protocols.clj 136]\n  [clojure.core.protocols$fn__8244 invoke protocols.clj 124]\n  [clojure.core.protocols$fn__8204$G__8199__8213 invoke protocols.clj 19]\n  [clojure.core.protocols$seq_reduce invokeStatic protocols.clj 31]\n  [clojure.core.protocols$fn__8236 invokeStatic protocols.clj 75]\n  [clojure.core.protocols$fn__8236 invoke protocols.clj
@faxm0dem
Copy link
Contributor Author

If I add a dummy param like this:

(defn now*
  "Sets the time of events to right now"
  [_ _ & children]
  (fn stream [event]
    (let [current-time (quot (System/currentTimeMillis) 1000)
          modevent (assoc event :time current-time)]
      (a/call-rescue modevent children))))

And use it like this:

(streams
  (stream {:name :now :default true}
    (custom :now [0] (index [:host :service]))))

It works...

@mcorbin
Copy link
Collaborator

mcorbin commented Oct 19, 2024

Hello,
I'm able to reproduce, I'll try to write an unit test to reproduce it within the codebase.

@mcorbin
Copy link
Collaborator

mcorbin commented Oct 22, 2024

At the moment passing a parameter is mandatory, also it seems I have a bug when nil is passed as parameter (in case you don't need it).
I'll see how to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants