Coder Social home page Coder Social logo

Comments (20)

ikitommi avatar ikitommi commented on August 29, 2024

hi!

the defroutes* is a good feature, but the current implementation sucks (doesn't resolve the symbols), there is already an issue out of it (#24). Might be easy to fix or then have to rewrite the whole walker to be namespace-aware. Now off to Euroclojure, will play with this after that.

cheers,

Tommi

from compojure-api.

dryewo avatar dryewo commented on August 29, 2024

Good luck! Spread the word about compojure-api!

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

thanks! :)

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

sorry for the lag on this, tried few solutions, none of them were elegant enough. Will return to this right after vacations. Current way to solve is to put all swaggered codes into same namespace as defapi and to import all stuff there. Butt-ugly, I know. Or to use pre 0.13.0-version which has still the global state.

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

discussed how to fix this properly. Will be fixed for the upcoming Swagger 2.0 version of both ring-swagger & compojure-api. Swagger 2.0 will have much better model for collecting routes, makes this fix much easier to implement. Will start to work on that this/next week. Until then, use the old version or import all stuff into the root hander (we are doing the latter currently).

from compojure-api.

dryewo avatar dryewo commented on August 29, 2024

Glad to hear that, thank you! I'm still using 0.12.0, can't wait to update.

from compojure-api.

gbuisson avatar gbuisson commented on August 29, 2024

Did anyone try creating a bigger API ?

With 20 routes, defapi seem to produce too much code for a single method, then we hit the java max method size limit:

Exception in thread "main" java.lang.RuntimeException: Method code too large!

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

hi.

Haven't bump into this. Despite of the namespace resolution bug, we have distributed large apis (60+ routes) with defroutes*.

Will try to find time next week to resolve this (the original issue).

from compojure-api.

gbuisson avatar gbuisson commented on August 29, 2024

I tried also with defroutes* and also using with-routes instead of defapi, same result:

lein uberjar

Compiling lightning.handler
java.lang.RuntimeException: Method code too large!
at clojure.asm.MethodWriter.getSize(MethodWriter.java:1872)
at clojure.asm.ClassWriter.toByteArray(ClassWriter.java:775)
at clojure.lang.Compiler.compile(Compiler.java:7382)
at clojure.lang.RT.compile(RT.java:398)
at clojure.lang.RT.load(RT.java:438)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5066.invoke(core.clj:5641)
at clojure.core$load.doInvoke(core.clj:5640)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5446)
at clojure.core$compile$fn__5071.invoke(core.clj:5652)
at clojure.core$compile.invoke(core.clj:5651)
at user$eval7$fn__14.invoke(form-init7592595820997304642.clj:1)
at user$eval7.invoke(form-init7592595820997304642.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6693)
at clojure.lang.Compiler.load(Compiler.java:7130)
at clojure.lang.Compiler.loadFile(Compiler.java:7086)
at clojure.main$load_script.invoke(main.clj:274)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invoke(main.clj:307)
at clojure.main$null_opt.invoke(main.clj:342)
at clojure.main$main.doInvoke(main.clj:420)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Exception in thread "main" java.lang.RuntimeException: Method code too large!, compiling:(/private/var/folders/4r/242337xj5x18_g14dlnwtcxc0000gn/T/form-init7592595820997304642.clj:1:4)

I tried, removing nearly all my routes, it works with just one, barely with 2 routes.
I comment on this issue because my first guess is that the macro generates a single too large method.

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

I couldn't reproduce this problem. Can you provide a minimalistic setup for a failed case?

from compojure-api.

gbuisson avatar gbuisson commented on August 29, 2024

I fixed it by "lazy loading" the routes, with something like:

(defn -main []
(require 'myapp.handler)
(let [app (eval `myapp.handler/app)](httpkit/run-server app {:port 8081
:thread 8})))

otherwise, if i pass handler directly to http-kit/run server it fails with "Method code too large!"
i think i saw another issue describing this behaviour but cannot find it.

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

great to hear you got it working! We used AOT for the routes in one app with tens of api-routes, worked ok in that - but the build times were really bad and din't seem to effect much in the startup time for some reason. Might be differences in the JVMs being used. Currently use the same lazy-loading in all apps.

from compojure-api.

gbuisson avatar gbuisson commented on August 29, 2024

Thank you for your support, this is a nice project, keep up the good work ;-)

from compojure-api.

Deraen avatar Deraen commented on August 29, 2024

The project Tommi mentioned used Jetty. We should maybe test AOT + Http-kit + large api?

from compojure-api.

gbuisson avatar gbuisson commented on August 29, 2024

I think it is not about ring vs http-kit, small or large API but more about aot.
i tested with only 2 routes and got the same result.

In http-kit case, you have to instanciate a server in your code and pass the api, then handler code is fully evaluated and compiled, then it breaks.

when you use ring, i think the server launches but code is evaluated in a JIT fashion.
thus the handler method is evaluated piece by piece and it still runs without breaking the method size limit.

if you specify full aot with ring, in my tests it also breaks.

let me know if you have the same behaviours or if you need more details.

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

I have AOTted lots of ring-apps, small and large, never had that error. If
you can reproduce this (via a github repo for example), would love to
investigate.

On Tue, Sep 9, 2014 at 3:00 PM, gbuisson [email protected] wrote:

I think it is not about ring vs http-kit, small or large API but more
about aot.
i tested with only 2 routes and got the same result.

In http-kit case, you have to instanciate a server in your code and pass
the api, then handler code is fully evaluated and compiled, then it breaks.

when you use ring, i think the server launches but code is evaluated in a
JIT fashion.
thus the handler method is evaluated piece by piece and it still runs
without breaking the method size limit.

if you specify full aot with ring, in my tests it also breaks.

let me know if you have the same behaviours or if you need more details.


Reply to this email directly or view it on GitHub
#33 (comment)
.

from compojure-api.

gbuisson avatar gbuisson commented on August 29, 2024

I'll try to make a repo as soon as i have more spare time.

I'll let you know.

Thank you.

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

will be fixed in https://github.com/metosin/compojure-api/tree/swagger2routes

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

fix merged to master, will be in [0.20.0]

from compojure-api.

dryewo avatar dryewo commented on August 29, 2024

wow thanks
finally we have it :)

from compojure-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.