{"id":22235361,"url":"https://github.com/niko-dunixi/ball-clock-simulator","last_synced_at":"2025-03-25T09:24:43.563Z","repository":{"id":78576282,"uuid":"145270083","full_name":"niko-dunixi/ball-clock-simulator","owner":"niko-dunixi","description":"A simulation written in Go that tracks the position of physical balls within registers to represent time","archived":false,"fork":false,"pushed_at":"2023-09-07T05:10:59.000Z","size":396,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-30T08:43:23.307Z","etag":null,"topics":["aws-lambda","ballclock","clock","golang","simulation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niko-dunixi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/BallClockSimulator.go","governance":null,"roadmap":null,"authors":null}},"created_at":"2018-08-19T03:29:12.000Z","updated_at":"2023-09-03T03:59:49.000Z","dependencies_parsed_at":"2023-12-21T05:21:52.365Z","dependency_job_id":"cc9a9e05-7039-4660-a7fa-03648798d95f","html_url":"https://github.com/niko-dunixi/ball-clock-simulator","commit_stats":null,"previous_names":["paul-nelson-baker/ball-clock-simulator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niko-dunixi%2Fball-clock-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niko-dunixi%2Fball-clock-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niko-dunixi%2Fball-clock-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niko-dunixi%2Fball-clock-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niko-dunixi","download_url":"https://codeload.github.com/niko-dunixi/ball-clock-simulator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245433212,"owners_count":20614452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","ballclock","clock","golang","simulation"],"created_at":"2024-12-03T02:12:59.098Z","updated_at":"2025-03-25T09:24:43.541Z","avatar_url":"https://github.com/niko-dunixi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ball Clock Simulator\nFor requirements refer to the [PDF](Rakuten-BallClockAssignment.pdf). I had never heard of a Ball Clock before this, I found [this video](https://youtu.be/F7K6GIBWPQw) helpful to understanding what a Ball Clock was and how it worked.\n\n## Roadmap\nThere is a lot that can be done to improve this. I didn't fully understand the assignment, nor did I have a good grasp on some of the Go interior workings. I've given myself the following homework:\n- [ ] Find a Go code profiler\n- [ ] Understand how Slices work (See [Issue #1](https://github.com/paul-nelson-baker/ball-clock-simulator/issues/1))\n- [ ] Reapproach my algorithms, potentially from the ground up, with the lessons learned to see if we can make all calls sub-second speed\n\n## Installation\nYou have to have:\n- [Go](https://golang.org/dl/) installed to you machine\n- [Dep](https://github.com/golang/dep) installed\n- retrieve this and initialize the codebase:\n    ```\n    go get github.com/paul-nelson-baker/ball-clock-simulator\n    cd ~/go/src/github.com/paul-nelson-baker/ball-clock-simulator\n    dep ensure\n    ```\n\n## Executing the main application\nYou can run the convenience scripts provided:\n- `test-tdd.sh`\n    - This will run unit tests for the codebase\n- `run-cli-simulation.sh`\n    - This will start the interactive application\n\n![alt Application running in terminal](images/main-app.jpg)\n\n## Executing as an AWS Lambda\nSince IaaS and FaaS are relatively simple for small projects, and [Go Build supports build tags](https://dave.cheney.net/2013/10/12/how-to-use-conditional-compilation-with-the-go-build-tool) we can use the same codebase to run our CLI application as a REST endpoint. Compilation branching isn't usually advisable unless you're specifically doing it to support multiple platforms. In this case it's a simple way to include a secondary main method for AWS.\n\nThis requires the following installed and available on your terminal PATH:\n- [aws-sam-cli](https://github.com/awslabs/aws-sam-cli) so we can run as an AWS Lambda with API Gateway locally\n- [curl](https://curl.haxx.se/) to make REST requests\n- [jq](https://stedolan.github.io/jq/) so we can pretty-print the output to the console\n\nOnce you have all requirements met, open two separate terminals.\n- In the first terminal run: `run-aws-simulation.sh`\n    - This will start SAM-CLI and bind the API to default port 3000 \n- In the second terminal run: `test-aws-curls.sh`\n    - This will run all unit tests first \n    - Then it will curl the endpoint for data with the given inputs\n        - Mode 1 with 30 Balls\n        - Mode 1 with 45 Balls\n        - Mode 2 with 30 Balls and 325 iterations\n\n![alt Application running as Lambda](images/main-lambda.jpg)\n\n\nNote: If you wish to deploy this to an AWS environment, you must include a `CodeUri` as part of the cloud-formation template. This must point to a valid artifact in S3. This requires either manually uploading a file or creating a devops build/test/deploy pipeline, which is currently outside the scope of this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniko-dunixi%2Fball-clock-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniko-dunixi%2Fball-clock-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniko-dunixi%2Fball-clock-simulator/lists"}