0

I am building a Rails service that uses Server-Sent Events (SSE) to stream events to the browser. There is a controller with standard RESTful endpoints for manipulating / querying data, and then another controller (inheriting from ActionController::Live) that handles the asynchronous code. Then, in the middle I have Redis as a pubsub

Because I am pre-computing the messages I'd like to send in the RESTful controller, I do not use the database in the SSE controller (the auth does not require a database connection).

The Problem:

Because the database connection is being unnecessarily grabbed from the pool, I am limited in the number of connections, but the number of database connections I allow.

Question:

Is there a way to skip_before_filter (or similar) to avoid requiring a database connection?

2
  • 1
    There shouldn't be a reason why a controller would create a database connection. That is a models responsibility. Can you please post your controller? Commented May 22, 2015 at 22:16
  • No, there is no user authentication being done (in the traditional sense at least). Instead we're just using a signed token, and we don't need to check if that user exists in the database. Commented May 22, 2015 at 23:15

1 Answer 1

0

You can disable db connections by default. I think this SO post tells you how:

Rails 3 - how do I avoid database altogether?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.