{"id":21043104,"url":"https://github.com/mrinalxdev/go-load","last_synced_at":"2025-06-16T00:05:45.584Z","repository":{"id":238822825,"uuid":"797664097","full_name":"mrinalxdev/Go-load","owner":"mrinalxdev","description":"Backend loadbalancer in golang","archived":false,"fork":false,"pushed_at":"2024-05-09T01:32:38.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-09T10:46:24.005Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mrinalxdev.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":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-08T09:24:17.000Z","updated_at":"2024-06-19T10:12:39.200Z","dependencies_parsed_at":"2024-05-08T10:43:07.078Z","dependency_job_id":"716fa355-ffd9-42d0-a30c-3960d87a0050","html_url":"https://github.com/mrinalxdev/Go-load","commit_stats":null,"previous_names":["mrinalxdev/go-load"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mrinalxdev/Go-load","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2FGo-load","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2FGo-load/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2FGo-load/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2FGo-load/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrinalxdev","download_url":"https://codeload.github.com/mrinalxdev/Go-load/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2FGo-load/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260072462,"owners_count":22954910,"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":[],"created_at":"2024-11-19T14:10:58.151Z","updated_at":"2025-06-16T00:05:45.551Z","avatar_url":"https://github.com/mrinalxdev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Load Balancer Implementation in Go\n\nThis Go project demonstrates a simple load balancer implementation using a round-robin strategy. Let's break down the components and functionalities:\n\n## Server Interface\n\n- This interface defines the methods required for a server:\n  - `Address() string`: Returns the address of the server.\n  - `IsAlive() bool`: Checks if the server is alive.\n  - `Serve(rw http.ResponseWriter, r *http.Request)`: Serves HTTP requests.\n\n## SimpleServer Struct\n\n- Implements the `Server` interface.\n- Contains an address and a reverse proxy for forwarding requests.\n- `newSimpleServer`: Constructs a new `simpleServer` instance.\n\n## LoadBalancer Struct\n\n- Manages a pool of servers and distributes requests among them.\n- Keeps track of the current round-robin count.\n- Provides a method `getNextAvailableServer()` to fetch the next available server based on the round-robin strategy.\n- `NewLoadBalancer`: Constructs a new `LoadBalancer` instance.\n\n## handleErr Function\n\n- Handles errors by printing them and exiting the program if an error occurs.\n\n## Address Function\n\n- Returns the address of a simple server.\n\n## LoadBalancer Methods\n\n- `serveProxy`: Proxies incoming HTTP requests to the next available server obtained from `getNextAvailableServer()`.\n\n## Main Function\n\n- Initializes a list of servers with different addresses (Facebook, Bing, DuckDuckGo).\n- Creates a load balancer instance with the specified port and the list of servers.\n- Defines a request handler function (`handleRedirect`) to forward incoming requests to the load balancer.\n- Starts an HTTP server to listen for incoming requests on the specified port.\n- Prints a message indicating that the server is running.\n\nOverall, this project demonstrates a basic implementation of a load balancer in Go, where incoming requests are distributed among multiple backend servers using a round-robin algorithm. The `net/http` package is used for handling HTTP requests and responses, and the `httputil` package is utilized for reverse proxying.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrinalxdev%2Fgo-load","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrinalxdev%2Fgo-load","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrinalxdev%2Fgo-load/lists"}