Comments (20)
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.
Good luck! Spread the word about compojure-api!
from compojure-api.
thanks! :)
from compojure-api.
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.
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.
Glad to hear that, thank you! I'm still using 0.12.0, can't wait to update.
from compojure-api.
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.
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.
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.
I couldn't reproduce this problem. Can you provide a minimalistic setup for a failed case?
from compojure-api.
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.
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.
Thank you for your support, this is a nice project, keep up the good work ;-)
from compojure-api.
The project Tommi mentioned used Jetty. We should maybe test AOT + Http-kit + large api?
from compojure-api.
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.
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.
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.
will be fixed in https://github.com/metosin/compojure-api/tree/swagger2routes
from compojure-api.
fix merged to master, will be in [0.20.0]
from compojure-api.
wow thanks
finally we have it :)
from compojure-api.
Related Issues (20)
- OpenAPI? HOT 5
- Add {:coercion :select-schema} option
- muuntaja encoder modifying swagger.json output HOT 1
- Vulnerability issue in dependent lib
- Missing security and deprecated meta
- Memory use rises with requests HOT 3
- Can't get Swagger UI to provide interface for arbitrary query params HOT 2
- fix broken url link in docs
- Clj-kondo linting issue HOT 2
- Consider bumping to Compojure 1.7.0 or Compojure 1.6.3
- Mixing compojure.api.sweet/defapi and compojure.core/defroutes
- How do I specify an optional field when accepting multipart-params for a request?
- Compojure 2.x should be backwards compatible with 1.x HOT 3
- Automatically push `context` parameters into endpoints when safe HOT 3
- Calculate coercers/schemas outside contexts when not dependent on request
- Pull out static parts of an otherwise-dynamic context
- Compile to non-linear routing strategies
- Immutable `restructure` interface
- Potential memory leak
- java.lang.AbstractMethodError and dependency mess HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compojure-api.