Giter Club home page Giter Club logo

garageevents's Introduction

Garage events

This solution contains a small experiment in how to use events at different levels. The solution consists of an imaginary garage with a door and lights. The solution is built to be used in > .NET8 and is using Microsoft.Extensions for logging, configuration, dependency injection etc.

The applications to test the garage is made as two different solutions, one microservice oriented with four separate applications and one modular monolith.

The door can be opened and closed and the light could be turned on and off. A Remote control is used to control the door and the light. It all circles around the events that are raised when the remote is triggered.

The assembly GarageEvents contains different abstractions for the garage, the door, the light and the remote control.
It also contains the implementation of the garage, the door, the light and a default behavior for a remote control. The default remote control is using plain events to signal the actions.

The assembly GarageEvents.Nats contains an implementation of the IRemote interface that uses asynchronous event streaming to send the events between multiple applications. The idea is to be able to have one application for each part.

To be able to run the sample you will need to have a nats server running. You can download the server from nats.io. Remember to start it with the commandline switch --js to enable the streaming server.

To show the full implementation there are four sample applications (think of them as microservices) all taking care of each part of the scenario, one for the remote, one for the garage, one for the door and one for the light and they are using the event stream to talk with each others. There is also an application called MonolithTest that will include all the functionality in the four microservicerelated applications, in this application it is easy to switch between internal and external events.

This sample is not meant to be a full implementation of a garage, it is just a small experiment in how to use events at different levels. There is a lot of things that could be added to make it more realistic, like a sensor for the door, a timer for the light and so on. Furthermore it is not written to be an example of SOLID or any particular level of clean code. Lots of the code could even be considered ugly and in some cases perhaps even bad practice.

But it could actually be implemented in real life by using one or a couple of Raspberry Pi's, some wirings, some sensors, a wifi connection and some relays.

If you have any questions or comments, please feel free to contact me.

garageevents's People

Contributors

lennartajansson avatar

Watchers

 avatar

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.