Simple mock program to set charging rate of a battery instance based on the national grid intensity api

Charger

Simple mock program to set charging rate of a battery instance based on the national grid intensity api.

Steps to get up and running

I have created two different services, as the spec wasn't very clear as to what they refer to as a "microservice". Although both are very similar in nature, one is a http api that starts a scheduler (charge-api) and the other one (called charge) is a simple command line program application that could be run in the background of microcontrollers with an in-build scheduler (charge), so no need to setup cron on these microcontrollers (although haven't tested this with Tiny Go so might need a few tweaks to get it to work on microcontrollers).

The charge-api is almost identical to charge except that this has a net/http switch to turn the scheduler on or off using the endpoints /start or /stop.

To run both, you can just build them similar to how all go applications are built. For example, to run charge you can run the following in your terminal (linux or macos)

cd cmd/charge
go build .
./charge

to run charge-api, similary just build and run as before except you should just change directory to cmd/charge-api

cd cmd/charge-api
go build .
./charge-api

The usage of charge is quite simple by design. The idea is very simple (I have assumed a few things because the spec wasn't detailed in terms of the timing of the api national grid api was being used.) The charge application simply starts a scheduler like ticker, and runs at every half hour interval at hh:00 and hh:30 (roughly.) The logic for this is quite simple, but I wasn't sure if this is what was asked so I created another one because I wasn't sure what their definition of a microservice is.

The charge-api on the other hand is /start and /stop endpoints to start the scheduler similar to charge. I think there is definitely a lot of things that could be improved in the charge-api but I didn't have a lot of time to explore other options.

Do let me know if you have any questions!

NOTE: I have profiled charge extensively to see what the energy impact of this is and for two hours that I kept this running it only took about 7mb of memory and negligible cpu usage, in case this is an important factor.

Owner
Taj
A math undergrad in University of Oxford. Love maths, programming and finding optimal solutions for computational problems.
Taj
Similar Resources

Powerful mock generation tool for Go programming language

Summary Minimock generates mocks out of Go interface declarations. The main features of minimock are: It generates statically typed mocks and helpers.

Dec 17, 2022

Mock object for Go http.ResponseWriter

mockhttp -- Go package for unit testing HTTP serving Unit testing HTTP services written in Go means you need to call their ServeHTTP receiver. For thi

Sep 27, 2022

ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format

ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format. This service can then simply be consumed by any client to get the expected response.

Mar 2, 2021

mockery - A mock code autogenerator for Golang

mockery - A mock code autogenerator for Golang

mockery - A mock code autogenerator for Golang

Jan 8, 2023

Create your own mock server with just a JSON file!

Gmocker Run a blazing fast mock server in just seconds! 🚀 All you need is to make a json file that contains path and response mapping. See an example

Dec 21, 2022

Create your own blazing fast mock server with just a JSON file!

Gmocker Run a blazing fast mock server in just seconds! 🚀 All you need is to make a json file that contains path and response mapping. See an example

Dec 21, 2022

Apple Push Notification service (APNs) mock server

APNs Mock Server Server

Dec 8, 2022

Completely type-safe compile-time mock generator for Go

Mockc Mockc is a completely type-safe compile-time mock generator for Go. You can use it just by writing the mock generators with mockc.Implement() or

Aug 25, 2022

Merge Mock - testing tool for the Ethereum Merge

MergeMock Experimental debug tooling, mocking the execution engine and consensus node for testing. work in progress Quick Start To get started, build

Oct 21, 2022
Vault mock - Mock of Hashicorp Vault used for unit testing

vault_mock Mock of Hashicorp Vault used for unit testing Notice This is a person

Jan 19, 2022
Mock-the-fck - Mock exercise for human

Mock the fck Originally, Mockery-example Example case for mockery issue #128 fil

Jan 21, 2022
Selenium Hub successor running browsers within containers. Scalable, immutable, self hosted Selenium-Grid on any platform with single binary.
Selenium Hub successor running browsers within containers. Scalable, immutable, self hosted Selenium-Grid on any platform with single binary.

Selenoid Selenoid is a powerful implementation of Selenium hub using Docker containers to launch browsers. Features One-command Installation Start bro

Jan 5, 2023
📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.
 📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.

mock ?? mock is a simple, cross-platform, cli app to simulate HTTP-based APIs. About mock Mock allows you to spin up a local http server based of a .m

May 6, 2022
This is a simple test application that sends fake video data from one pion instance to another

Pion test app for BWE This is a simple test application that sends fake video data from one pion instance to another. It is a modified version of the

Jun 8, 2022
Mock API for REST!!!!

Mock API Server Introduction This app allows you to add urls and serve dummy json responses. It contains two handlers, the DummyHandler allows you to

Jun 20, 2022
mock server to aid testing the jaguar-java client API

stripe-mock stripe-mock is a mock HTTP server that responds like the real Stripe API. It can be used instead of Stripe's test mode to make test suites

Dec 24, 2021
A simple mock server configurable via JSON, built using GoLang.
A simple mock server configurable via JSON, built using GoLang.

GoMock Server A simple mock server configurable via JSON, built using GoLang. How To A file name endpoint.json must be placed in the context root, wit

Nov 19, 2022
Sql mock driver for golang to test database interactions

Sql driver mock for Golang sqlmock is a mock library implementing sql/driver. Which has one and only purpose - to simulate any sql driver behavior in

Dec 31, 2022
HTTP mock for Golang: record and replay HTTP/HTTPS interactions for offline testing

govcr A Word Of Warning I'm in the process of partly rewriting govcr to offer better support for cassette mutations. This is necessary because when I

Dec 28, 2022