Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign current architecture #21

Open
zabawaba99 opened this issue Aug 4, 2015 · 4 comments
Open

Redesign current architecture #21

zabawaba99 opened this issue Aug 4, 2015 · 4 comments
Milestone

Comments

@zabawaba99
Copy link
Collaborator

Based off #18


It feels a bit odd having to pass something down from main, to the builder to a vow and then to a promise just to have verbose output.

This was referenced Aug 4, 2015
@zabawaba99 zabawaba99 added this to the v1.0.1 milestone Aug 6, 2015
@zabawaba99 zabawaba99 modified the milestones: v1.1.1, v1.1.0 Oct 13, 2015
@Tonkpils Tonkpils modified the milestones: v1.3.0, v1.2.0 Feb 21, 2016
@Tonkpils
Copy link
Owner

@zabawaba99 I figured we have this issue here we can talk about the design here and use this. I've created a branch to get started on the work. Once we have something discussed here we can add changes and make a PR to track those changes

@Tonkpils Tonkpils changed the title Consider redesigning how the builder and vow package interact Redesign current architecture Feb 21, 2016
@zabawaba99
Copy link
Collaborator Author

From the brief discussion we had I put together an extremely rough sketch of the redesign might look like.

screen shot 2016-02-20 at 8 11 07 pm

Overview

The concept would revolve around having an object that allows us to exchange messages between components (labeled Exchange in the image above). All components would register with the exchange and tell it what events it expects.

Exchange

The purpose of the exchange is to accept messages and route them to the appropriate consumer.

File System Watcher

This component is in charge of watching the file system. Whenever a file is modified, it will send a message through the exchange to notify that the tasks should be run.

Messages Sent

  • "rebuild"

Messages Received

  • n/a

Task Executor

This component is in charge of running the build/run steps in the snag file. It will register itself against the exchange and listen for a message telling it to rebuild. While building 3 events will be emitted per command that is ran. The exchange will be notified when a command is about to start, is in progress and is finished.

Messages Sent

  • "cmd_starting" "<cmd_details>"
  • "cmd_running" "<cmd_details>"
  • "cmd_finished" "<cmd_details>"

Messages Received

  • "rebuild"

UI

This component is in charge of building and managing the terminal ui. It will register against the exchange and listen for messages telling it about the status of the processes running.

Messages Sent

  • n/a

Messages Received

  • "cmd_starting" "<cmd_details>"
  • "cmd_running" "<cmd_details>"
  • "cmd_finished" "<cmd_details>"

@zabawaba99
Copy link
Collaborator Author

And alternative to the exchange would be to abstract components into interfaces something like:

screen shot 2016-02-22 at 9 18 26 pm

(I got a little lazy with the drawing 👯 )

Where the top level are the interfaces and the lower level are implementations of said interface. This would allow us to create a Notifier with a Runner interface. Whenever the Notifier deems that a new build should run it would call a method on the running, perhaps something like runner.Run().

This design would also allow us to plug and play components and keep the code modularized and clean. We can get into a bit more detail regarding this design if we choose to go with this one over the exchange.

zabawaba99 added a commit that referenced this issue Mar 5, 2016
Created packages for each component and tied them together in the main class
@Tonkpils
Copy link
Owner

Changes can be followed on https://github.com/Tonkpils/snag/tree/decouple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants