{"id":20052429,"url":"https://github.com/hyperjiang/lunar","last_synced_at":"2025-05-05T11:32:27.400Z","repository":{"id":57521966,"uuid":"252326899","full_name":"hyperjiang/lunar","owner":"hyperjiang","description":"Probably the most elegant ctrip apollo client in golang. This library has no third-party dependency.","archived":false,"fork":false,"pushed_at":"2024-10-11T08:34:07.000Z","size":37,"stargazers_count":12,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T22:41:34.510Z","etag":null,"topics":["apollo","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperjiang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-04-02T01:34:44.000Z","updated_at":"2024-10-11T08:34:11.000Z","dependencies_parsed_at":"2024-03-09T14:07:51.007Z","dependency_job_id":null,"html_url":"https://github.com/hyperjiang/lunar","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperjiang%2Flunar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperjiang%2Flunar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperjiang%2Flunar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperjiang%2Flunar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperjiang","download_url":"https://codeload.github.com/hyperjiang/lunar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252489201,"owners_count":21756285,"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":["apollo","golang"],"created_at":"2024-11-13T12:17:39.411Z","updated_at":"2025-05-05T11:32:27.104Z","avatar_url":"https://github.com/hyperjiang.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lunar\n\n[![GoDoc](https://godoc.org/github.com/hyperjiang/lunar?status.svg)](https://godoc.org/github.com/hyperjiang/lunar)\n[![CI](https://github.com/hyperjiang/lunar/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/hyperjiang/lunar/actions/workflows/ci.yml)\n[![](https://goreportcard.com/badge/github.com/hyperjiang/lunar)](https://goreportcard.com/report/github.com/hyperjiang/lunar)\n[![codecov](https://codecov.io/gh/hyperjiang/lunar/branch/master/graph/badge.svg)](https://codecov.io/gh/hyperjiang/lunar)\n[![Release](https://img.shields.io/github/release/hyperjiang/lunar.svg)](https://github.com/hyperjiang/lunar/releases)\n\nProbably the most elegant ctrip apollo client in golang. This library has no third-party dependency.\n\nCtrip Apollo: https://github.com/ctripcorp/apollo\n\nDefault settings of `lunar`:\n\n- default namespace is `application`\n- default server is `localhost:8080`\n- default http client timeout is `90s`\n\n*Require golang version \u003e= 1.16 after v0.6.0*\n\n## Usage\n\n```\nimport \"github.com/hyperjiang/lunar\"\n\nkey := \"foo\"\n\napp := lunar.New(\"myAppID\", lunar.WithServer(\"localhost:8080\"))\n\n// get value of key in default namespace\napp.GetValue(key)\n\n// get value of key in namespace ns\napp.GetValueInNamespace(key, \"ns\")\n\n// get all the items in default namespace\napp.GetItems()\n\n// get all the items in namespace ns\napp.GetItemsInNamespace(\"ns\")\n\n// get the content of ns namespace, if the format of ns is properties then will return json string\napp.GetContent(\"ns\")\n\n// it will fetch items from apollo directly without reading local cache\napp.GetNamespaceFromApollo(\"ns\")\n\n// watch changes of given namespaces\nwatchChan, errChan := app.Watch(\"ns1\", \"ns2\", ...)\n\nfor {\n\tselect {\n\tcase n := \u003c-watchChan:\n\t\tfmt.Println(n)\n\tcase \u003c-errChan:\n\t\tapp.Stop() // stop watcher\n\t\treturn\n\t}\n}\n```\n\n## Logging\n\n`lunar` does not write logs by default, if you want to see logs for debugging, you can replace it with any logger which implements `lunar.Logger` interface.\n\n`lunar` also provide a simple logger `lunar.Printf` which writes to stdout:\n\n```\napp := lunar.New(\"myAppID\", lunar.WithServer(\"localhost:8080\"), lunar.WithLogger(lunar.Printf))\n```\n\nOr you can use `UseLogger` method:\n\n```\napp.UseLogger(lunar.Printf)\n```\n\n## Caching\n\n`lunar` use memory cache by default, you can replace it with any cache which implements `lunar.Cache` interface.\n\n`lunar` also provide a file cache `lunar.FileCache` which use files for caching:\n\n```\napp := lunar.New(\"myAppID\")\n\napp.UseCache(lunar.NewFileCache(\"myAppID\", \"/tmp\"))\n```\n\n## Enable Access Key\n\nStarting from v1.6.0, apollo supports access key feature, you can use `WithAccessKeySecret` to set the secret:\n\n```\napp := lunar.New(\n\t\"myAppID\",\n\tlunar.WithServer(\"localhost:8080\"),\n\tlunar.WithAccessKeySecret(\"mySecret\"),\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperjiang%2Flunar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperjiang%2Flunar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperjiang%2Flunar/lists"}