Giter Site home page Giter Site logo

Framework freeze about controller HOT 4 CLOSED

hanami avatar hanami commented on May 17, 2024
Framework freeze

from controller.

Comments (4)

ukutaht avatar ukutaht commented on May 17, 2024

A couple questions:

  • Should the freeze be irreversible? Should one be able to 'unfreeze' a configuration?
  • Is there a simple way to get at every controller and action in an application?
  • Shouldn't application boot logic live in the 'lotus' gem?

from controller.

jodosha avatar jodosha commented on May 17, 2024

@Heruku Hey thanks for those questions.

  • Yes, I see this process as irreversible, because it has production environment in mind. The plan is load and then freeze, in order to prevent accidental changes.
  • There isn't. What's your use case? We can discuss about this and improve things.
  • Code loading and framework duplication aren't thread safe. For this reason the loading context should be thread safe. For instance, Lotus::Loader wraps those operations with a critical section. Now, if this framework is used outside of a full stack application (aka without lotusrb gem), I want to provide a single entry point for developers to trigger. Eg. Lotus::Controller.load!.

from controller.

ukutaht avatar ukutaht commented on May 17, 2024

@jodosha Thanks for the reply, you made things much clearer

I can come up with a couple ways to freeze a single configuration:

  • There could be a flag on the configuration class whether it can be mutated (not the cleanest way in my opinion, too many added conditionals and possible errors)
  • freeze! method could undefine setter methods (I'd like to stay away from metaprogramming)
  • freeze! method could return a new immutable configuration class. A read-only value object that can be derived from the existing configuration.

These are some ideas for freezing a single configuration, but I'm having a hard time seeing how we could freeze all configurations. This is why I asked the second question - to provide a single entry point like Lotus::Controller.load!, we must be able to iterate over all controllers and actions defined to freeze them.

Am I missing something?

from controller.

jodosha avatar jodosha commented on May 17, 2024

@Heruku So you were asking because of the implementation of this feature, not for an use case that you have. Is that right?

Yes, we definitely need a registry. Lotus::View has it, it powers .load!. Now, when I implemented that mechanism in that framework, it was only because I needed to preload templates and do other preparatory work. However, it only was considering the point of this discussion. In other words, we need to rethink the code for both the libraries.

from controller.

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.