GithubHelp home page GithubHelp logo

Add Web UI about sidekiq.cr HOT 6 CLOSED

mperham avatar mperham commented on July 16, 2024 3
Add Web UI

from sidekiq.cr.

Comments (6)

sdogruyol avatar sdogruyol commented on July 16, 2024 2

I'd be happy to help you about any Kemal related question 👍

from sidekiq.cr.

mperham avatar mperham commented on July 16, 2024

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.

sdogruyol avatar sdogruyol commented on July 16, 2024

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.

mperham avatar mperham commented on July 16, 2024

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.

danielpclark avatar danielpclark commented on July 16, 2024
# 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.

sdogruyol avatar sdogruyol commented on July 16, 2024

@danielpclark unfortunately, this is not implemented. Kemal only allows single app per single process (for now)

from sidekiq.cr.

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.