{"id":18410119,"url":"https://github.com/jomoespe/clarity-challenge","last_synced_at":"2025-04-12T21:58:45.601Z","repository":{"id":95258758,"uuid":"188170978","full_name":"jomoespe/clarity-challenge","owner":"jomoespe","description":"Clarity challenge repository","archived":false,"fork":false,"pushed_at":"2019-06-12T19:01:57.000Z","size":274,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T21:58:42.109Z","etag":null,"topics":["challenge","clarity","go","golang","log-processor"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jomoespe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-23T06:01:57.000Z","updated_at":"2019-06-12T19:01:59.000Z","dependencies_parsed_at":"2023-03-14T00:01:12.386Z","dependency_job_id":null,"html_url":"https://github.com/jomoespe/clarity-challenge","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomoespe%2Fclarity-challenge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomoespe%2Fclarity-challenge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomoespe%2Fclarity-challenge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomoespe%2Fclarity-challenge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jomoespe","download_url":"https://codeload.github.com/jomoespe/clarity-challenge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637784,"owners_count":21137538,"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":["challenge","clarity","go","golang","log-processor"],"created_at":"2024-11-06T03:29:09.208Z","updated_at":"2025-04-12T21:58:45.576Z","avatar_url":"https://github.com/jomoespe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clarity backend code challenge\n\n[![Build Status](https://travis-ci.com/jomoespe/clarity-challenge.svg?token=pvtAthG3oqWcKLGsBRBA\u0026branch=master)](https://travis-ci.com/jomoespe/clarity-challenge)\n\nThis project is my implementation of [Clarity](https://clarity.ai/) [blackend code challlenge](./docs/clarity_code_challenge.pdf).\n\n## Solution description\n\nBased on requirements I've created two programs:\n\n- `listhosts` to implement first requirement: *Parse the data with time_init and time_end*.\n- `parselog` to implement second requirement: *Unlimited input parser*.\n\nAlso, I've creatd an utility, `log-generator` for testing purposes. It generates a log line (`timestamp source-source target-host`) every 100 milliseconds in standard output.\n\nThe project structure is based on [Standard Go Project Layout](https://github.com/golang-standards/project-layout).\n\n### Why Go languaje?\n\nThe requirements are about processing files, so, generating a native application looks like the more natural way to implement it. This ease the integration with other tools, allowing orchestration, piping with other utilities, etc; let's say *as much POSIX as possible*.\n\nAlso, taking into account that are like a *system applications*, using a language optimized for this things will help to improve performance and resource consumption.\n\n## Build the project\n\n### Requirements\n\n- [Go 1.11+](https://golang.org/), as programming language.\n- [GNU Make](https://www.gnu.org/software/make/) as build automation tool.\n\n### Project struxcrture\n\nThe source file for three programs are located in [cmd/](cmd/) folder. There are an main package for each program: `listhost`, `parselog`and `logsupplier`.\n\nThere are two code packages:\n\n- `logparser` with common behaviour, line *opening the file reader* or *parsing a log line*.\n- `types` with the data types used by program (`set` and `hostconnections`)\n\n### How to build\n\n```bash\nmake\n```\n\nThis build the binaries `listhosts`, `parselog` and `log-generator` in the project root directory.\n\n## Running the programs\n\n### Parse the data with time_init and time_end (`listhosts`)\n\nPrint a list of hostnames connected to the given host during the given period\n\n```bash\n./listhosts [-start=time_init] [-end=time_end] [-host=hostname] [-v] [-h] [FILE]\n```\n\n| Parameter          | Description                                               |\n|--------------------|-----------------------------------------------------------|\n| `-start=time_init` | The start date. Defaul is from begining                   |\n| `-end=time_end`    | The end date. Default is to the end                       |\n| `-host=hostname`   | The host to find. Default is all host                     |\n| `-v`               | Print errors and warnings in stardard error               |\n| `-h`               | Show command line arguments and exit                      |\n| `FILE`             | The file to process. If no file it process standard input |\n\nExamples:\n\n```bash\n# all host related to *Aadvik* between two dates from a file.\n./listhosts -start=1565647205599 -end=1565687511867 -host=Aadvik -v test/input-file-10000.txt\n\n# all host related to *Aadvik* from standard input (piped)\ncat test/input-file-10000.txt | ./listhosts -host=Aadvik\n\n# count all host related to *Aadvik* from standard input (piping stdin and stdout)\ncat test/input-file-10000.txt | ./listhosts -host=Aadvik | wc -l\n```\n\n### Unlimited input parser (`parselog`)\n\nProcess a log file and, for a period of time, reports:\n\n- a list of hostnames connected to the given host.\n- a list of hostnames received connections from given host.\n- the hostname that generated most connections.\n\n```bash\n./parselog [-host=hostname] [-lapse=seconds] [FILE]\n```\n\n| Parameter        | Description                                                 |\n|------------------|-------------------------------------------------------------|\n| `-host=hostname` | The host to find. Default is no host                        |\n| `-lapse=seconds` | Number of seconds to gererate report. Default 3600 (1 hour) |\n| `FILE`           | The file to process. If no file it process standard input   |\n\nExamples:\n\n```bash\n# Parse a file looking for connections with 'Aadvik' host\n./parselog -host=Aadvik test/input-file-10000.txt\n\n# Parse logs from input stream, generating report each 10 seconds for host dijkstra\n./log-generator | ./parselog -lapse=10 -host=dijkstra\n```\n\n### Ramdom log lines provider (`log-generator`)\n\nTo help running the samples, I've created an small tool that generates log lines in the stardanr output each 100 Milliseconds.\n\n| Parameter             | Description                                                 |\n|-----------------------|-------------------------------------------------------------|\n| `-delay=milliseconds` | Number of milliseconds to wait between log line generation  |\n\n```bash\n./log-generator [-delay=milliseconds]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjomoespe%2Fclarity-challenge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjomoespe%2Fclarity-challenge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjomoespe%2Fclarity-challenge/lists"}