{"id":19838516,"url":"https://github.com/metal-stack/masterdata-api","last_synced_at":"2026-03-11T11:36:55.077Z","repository":{"id":41814098,"uuid":"240517038","full_name":"metal-stack/masterdata-api","owner":"metal-stack","description":"Microservice to manage tenant and project entities","archived":false,"fork":false,"pushed_at":"2025-04-29T17:03:38.000Z","size":771,"stargazers_count":4,"open_issues_count":7,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-29T18:22:43.646Z","etag":null,"topics":["microservice"],"latest_commit_sha":null,"homepage":null,"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/metal-stack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-14T13:42:28.000Z","updated_at":"2025-04-22T08:42:52.000Z","dependencies_parsed_at":"2024-06-20T17:09:58.303Z","dependency_job_id":"d4dd4b11-8dd5-4bcd-9b16-5cf6b5c70aea","html_url":"https://github.com/metal-stack/masterdata-api","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metal-stack%2Fmasterdata-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metal-stack%2Fmasterdata-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metal-stack%2Fmasterdata-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metal-stack%2Fmasterdata-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metal-stack","download_url":"https://codeload.github.com/metal-stack/masterdata-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251924716,"owners_count":21666024,"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":["microservice"],"created_at":"2024-11-12T12:18:01.963Z","updated_at":"2026-03-11T11:36:50.058Z","avatar_url":"https://github.com/metal-stack.png","language":"Go","readme":"# masterdata-api\n\nThis Microservice provides the source of truth for master data.\n\n* tenant master-data\n  * name/desc\n* tenant settings\n  * cloud\n    * limit max projects\n    * limit max clusters\n  * cluster\n    * limit\n* tenant project\n  * settings\n    * limit max clusters\n* tenant members\n* tenant project members\n* version\n\n## Design\n\nThe services are exposed as grpc-services. The included client can be used\nin other services by simply importing it.\n\nThe data is stored in a generic way using a postgres database\nwith tables consisting of id and json-document fields.\n\nChanges to the data are reflected in a history table-twin per entity. When data\nis created, updated or deleted, the change is also written to the history table.\n\nThe main entities are generated from a `\u003ctype\u003e.proto`-file\nplus some additional mapping-code in a `\u003ctype\u003e.go` file.\nUsing a go-generate-statement the db-schema and some boilerplating code\nis generated using naming-conventions.\n\n## Initial Data\n\nIt is possible to insert data on startup, this is done by placing one ore more yaml documents into the `initdb.d` directory.\nMulti document yaml files are not supported at the moment. If the given version of the entity is lower or equal the entity version\nstored in the database, no create or update happens. Otherwise a update is executed.\nOn every error happening during initdb is logged, but the affected entity is not processed.\n\n## Build\n\n```bash\nmake all\n```\n\n## Run\n\n```bash\nmake postgres-up\n```\n\nStart client with extensive logging\n\n```bash\nmake clean protoc client\nGRPC_GO_LOG_VERBOSITY_LEVEL=99 GRPC_GO_LOG_SEVERITY_LEVEL=info bin/client\n```\n\nStart server\n\n```bash\nmake clean protoc server\nbin/server\n```\n\n## Metrics\n\n```bash\nhttp://localhost:2112/metrics\n```\n\n## pprof\n\n```bash\ngo tool pprof -http :8080 localhost:2113/debug/pprof/heap\ngo tool pprof -http :8080 localhost:2113/debug/pprof/goroutine\n```\n\n## Generics migration\n\nIn order to get rid of all the reflection based logic in `postgres.go`, we decided to migrate to generics which are available since go 1.18.\nThis leads to much nicer code to read and also brings some benefits regarding allocations. Performance is at the same level as the reflection based approach.\n\nTo measure the impact, a bunch of benchmarks have been implemented for all CRUD operations provided by `postgres.go`.\n\nResults comparing old(reflection based) vs. new(generics based):\n\n```plain\n\nname             old time/op    new time/op    delta\nGetTenant-16       92.9µs ±11%    94.4µs ± 5%     ~     (p=0.421 n=5+5)\nCreateTenant-16    3.06ms ± 9%    3.40ms ± 4%  +10.95%  (p=0.008 n=5+5)\nUpdateTenant-16    3.59ms ± 9%    3.81ms ±19%     ~     (p=0.548 n=5+5)\nFindTenant-16       259µs ±12%     224µs ± 3%  -13.75%  (p=0.008 n=5+5)\n\nname             old alloc/op   new alloc/op   delta\nGetTenant-16       5.68kB ± 0%    4.40kB ± 0%  -22.55%  (p=0.029 n=4+4)\nCreateTenant-16    10.8kB ± 0%     9.6kB ± 0%  -11.22%  (p=0.008 n=5+5)\nUpdateTenant-16    22.7kB ± 0%    19.0kB ± 0%  -16.26%  (p=0.008 n=5+5)\nFindTenant-16      7.15kB ± 0%    5.19kB ± 0%  -27.38%  (p=0.016 n=4+5)\n\nname             old allocs/op  new allocs/op  delta\nGetTenant-16          118 ± 0%        92 ± 0%  -22.03%  (p=0.008 n=5+5)\nCreateTenant-16       238 ± 0%       204 ± 0%  -14.29%  (p=0.008 n=5+5)\nUpdateTenant-16       500 ± 0%       408 ± 0%  -18.40%  (p=0.008 n=5+5)\nFindTenant-16         146 ± 0%       108 ± 0%  -26.03%  (p=0.008 n=5+5)\n\n```\n\nAs shown, performance is about the same, but allocations in terms of bytes and count have been reduced quite significant.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetal-stack%2Fmasterdata-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetal-stack%2Fmasterdata-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetal-stack%2Fmasterdata-api/lists"}