Comments (6)
I'd be happy to help you about any Kemal related question 👍
from sidekiq.cr.
The top-level DSL seems really cool at first glance but IMO it takes away a lot of capabilities. I'm really missing a more idiomatic OOP-based webapp style. Sinatra now provides something like this:
class Sidekiq::Web < Kemal::Base
public_folder "..."
get "/" do |env|
end
end
# Allow multiple webapps to be mounted
Kemal.serve("localhost", 8080, {
"/sidekiq" => Sidekiq::Web
"/something-else" => Another::Web
})
With that style, you could also implement testing helpers, a la Rack::Test:
require "kemal/spec"
def app
Sidekiq::Web
end
describe "web" do
it "should work" do
resp = app.route(:get, "/")
resp.code.should eq(200)
end
end
from sidekiq.cr.
Yeah, i'm pretty aware of that and would like to implement the classic
Sinatra style which lets you mount multiple apps.
from sidekiq.cr.
Done!
I was able to implement GET and POST helper methods to make the Ruby port easier. Allows me to spec like this:
post "/scheduled/#{job_params(*params)}", {"add_to_queue" => "true"}
assert_equal 302, last_response.status_code
assert_equal "/scheduled", last_response.headers["Location"]
get "/queues/default"
assert_equal 200, last_response.status_code
assert_match(/#{params.first["args"][2].to_s}/, last_response.body)
from sidekiq.cr.
# Allow multiple webapps to be mounted Kemal.serve("localhost", 8080, { "/sidekiq" => Sidekiq::Web "/something-else" => Another::Web })
Did this get implemented in a mountable way for Kemal? I've been writing Rails-like controllers with Kemal in danielpclark/crystal-rails-template
require "../app/controllers/*"
module Railslike
module Routes
include Controllers
get "/", &IndexController.to_proc
error 404, &Error404Controller.to_proc
end
end
Where each method I define (to_proc
in this instance) returns something like:
def self.to_proc
->(env : HTTP::Server::Context){
controller = new(env) # Evaluated in other controller context of type BaseController
controller.render(controller) # Pass context into layout renderer
}
end
This works very well for me. But I digress, has this been implemented to run Sidekiq mounted in an existing server instance of Kemal?
from sidekiq.cr.
@danielpclark unfortunately, this is not implemented. Kemal only allows single app per single process (for now)
from sidekiq.cr.
Related Issues (20)
- Namespace support HOT 2
- Periodic jobs HOT 6
- Getting started with some web framework HOT 6
- Can't run example in manjaro linux HOT 1
- Easy to swap with Ruby version of sidekiq? HOT 1
- Update redis to new version HOT 1
- Web Dashboard HOT 3
- Test Mode
- Sidekiq breaks with kemal-session shard. HOT 1
- Sidekiq web example is not compiling HOT 2
- Redis early access HOT 2
- Port to Crystal 1.0.0 HOT 5
- Issues connecting to Sidekiq Pro HOT 4
- Can't run tests HOT 5
- Move to GitHub Actions
- Dependency on baked_file_system commit that no longer exists HOT 6
- Can't send job to queue HOT 2
- Error: method Redis::TransactionApi#zadd must return (Int64 | String) but it is returning Redis::Future HOT 4
- Split this shard in sidekiq.cr and sidekiq-dashboard.cr
- Job not being executed HOT 2
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 sidekiq.cr.