biucingcli 0.9.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. biucingcli/__init__.py +5 -0
  2. biucingcli/cli.py +849 -0
  3. biucingcli/template_data/android/template/.editorconfig +9 -0
  4. biucingcli/template_data/android/template/.gitignore +26 -0
  5. biucingcli/template_data/android/template/.mise.toml +3 -0
  6. biucingcli/template_data/android/template/Brewfile +6 -0
  7. biucingcli/template_data/android/template/Makefile +103 -0
  8. biucingcli/template_data/android/template/README.md +163 -0
  9. biucingcli/template_data/android/template/app/build.gradle.kts +178 -0
  10. biucingcli/template_data/android/template/app/proguard-rules.pro +1 -0
  11. biucingcli/template_data/android/template/app/src/androidTest/java/app/HomeRouteUiTest.kt +21 -0
  12. biucingcli/template_data/android/template/app/src/main/AndroidManifest.xml +18 -0
  13. biucingcli/template_data/android/template/app/src/main/java/app/MainActivity.kt +36 -0
  14. biucingcli/template_data/android/template/app/src/main/res/values/strings.xml +4 -0
  15. biucingcli/template_data/android/template/app/src/main/res/values/themes.xml +8 -0
  16. biucingcli/template_data/android/template/app/src/test/java/app/AppSmokeTest.kt +19 -0
  17. biucingcli/template_data/android/template/build.gradle.kts +27 -0
  18. biucingcli/template_data/android/template/core/designsystem/build.gradle.kts +33 -0
  19. biucingcli/template_data/android/template/core/designsystem/src/main/java/designsystem/Components.kt +75 -0
  20. biucingcli/template_data/android/template/core/designsystem/src/main/java/designsystem/DesignTokens.kt +23 -0
  21. biucingcli/template_data/android/template/core/designsystem/src/main/java/designsystem/Theme.kt +110 -0
  22. biucingcli/template_data/android/template/core/model/build.gradle.kts +26 -0
  23. biucingcli/template_data/android/template/core/model/src/main/java/model/Greeting.kt +6 -0
  24. biucingcli/template_data/android/template/core/model/src/test/java/model/GreetingTest.kt +16 -0
  25. biucingcli/template_data/android/template/core/network/build.gradle.kts +26 -0
  26. biucingcli/template_data/android/template/core/network/src/main/java/network/AppEnvironment.kt +17 -0
  27. biucingcli/template_data/android/template/core/testing/build.gradle.kts +27 -0
  28. biucingcli/template_data/android/template/core/testing/src/main/java/testing/FakeAppEnvironmentProvider.kt +13 -0
  29. biucingcli/template_data/android/template/docs/release-delivery.md +68 -0
  30. biucingcli/template_data/android/template/docs/release-signing.properties.example +20 -0
  31. biucingcli/template_data/android/template/fastlane/.env.example +22 -0
  32. biucingcli/template_data/android/template/fastlane/Appfile +1 -0
  33. biucingcli/template_data/android/template/fastlane/Fastfile +121 -0
  34. biucingcli/template_data/android/template/feature/home/build.gradle.kts +35 -0
  35. biucingcli/template_data/android/template/feature/home/src/main/java/home/HomeRoute.kt +38 -0
  36. biucingcli/template_data/android/template/feature/settings/build.gradle.kts +34 -0
  37. biucingcli/template_data/android/template/feature/settings/src/main/java/settings/SettingsRoute.kt +35 -0
  38. biucingcli/template_data/android/template/gradle/libs.versions.toml +35 -0
  39. biucingcli/template_data/android/template/gradle/verification-metadata.xml +3462 -0
  40. biucingcli/template_data/android/template/gradle/wrapper/gradle-wrapper.jar +0 -0
  41. biucingcli/template_data/android/template/gradle/wrapper/gradle-wrapper.jar.sha256 +1 -0
  42. biucingcli/template_data/android/template/gradle/wrapper/gradle-wrapper.properties +10 -0
  43. biucingcli/template_data/android/template/gradle.properties +4 -0
  44. biucingcli/template_data/android/template/gradlew +252 -0
  45. biucingcli/template_data/android/template/gradlew.bat +94 -0
  46. biucingcli/template_data/android/template/scripts/artifact-info +11 -0
  47. biucingcli/template_data/android/template/scripts/bootstrap +17 -0
  48. biucingcli/template_data/android/template/scripts/doctor +133 -0
  49. biucingcli/template_data/android/template/scripts/setup-android-sdk +23 -0
  50. biucingcli/template_data/android/template/scripts/sync-gradle-wrapper +19 -0
  51. biucingcli/template_data/android/template/scripts/verify-gradle-supply-chain +61 -0
  52. biucingcli/template_data/android/template/scripts/verify-release-artifact +104 -0
  53. biucingcli/template_data/android/template/settings.gradle.kts +25 -0
  54. biucingcli/template_data/android/template.json +146 -0
  55. biucingcli/template_data/apple/template/.gitignore +28 -0
  56. biucingcli/template_data/apple/template/.mise.toml +4 -0
  57. biucingcli/template_data/apple/template/.swiftformat +10 -0
  58. biucingcli/template_data/apple/template/.swiftlint.yml +33 -0
  59. biucingcli/template_data/apple/template/App/Config/ProjectDescriptionHelpers/Module.swift +6 -0
  60. biucingcli/template_data/apple/template/App/Config/XCConfig/Base.xcconfig +4 -0
  61. biucingcli/template_data/apple/template/App/Project.swift +66 -0
  62. biucingcli/template_data/apple/template/App/Targets/App/Resources/.gitkeep +1 -0
  63. biucingcli/template_data/apple/template/App/Targets/App/Sources/AppEntry.swift +9 -0
  64. biucingcli/template_data/apple/template/App/Targets/App/Sources/HomeView.swift +18 -0
  65. biucingcli/template_data/apple/template/App/Targets/App/Sources/HomeViewModel.swift +38 -0
  66. biucingcli/template_data/apple/template/App/Targets/AppTests/Sources/AppTests.swift +59 -0
  67. biucingcli/template_data/apple/template/Brewfile +8 -0
  68. biucingcli/template_data/apple/template/Makefile +128 -0
  69. biucingcli/template_data/apple/template/Packages/AppServices/Package.swift +20 -0
  70. biucingcli/template_data/apple/template/Packages/AppServices/Sources/AppServices/StarterMetadata.swift +52 -0
  71. biucingcli/template_data/apple/template/Packages/DesignSystem/Package.swift +20 -0
  72. biucingcli/template_data/apple/template/Packages/DesignSystem/Sources/DesignSystem/Theme.swift +8 -0
  73. biucingcli/template_data/apple/template/README.md +133 -0
  74. biucingcli/template_data/apple/template/Tuist.swift +8 -0
  75. biucingcli/template_data/apple/template/Workspace.swift +11 -0
  76. biucingcli/template_data/apple/template/docs/release-delivery.md +55 -0
  77. biucingcli/template_data/apple/template/fastlane/.env.example +20 -0
  78. biucingcli/template_data/apple/template/fastlane/Appfile +3 -0
  79. biucingcli/template_data/apple/template/fastlane/Fastfile +126 -0
  80. biucingcli/template_data/apple/template/fastlane/Matchfile +7 -0
  81. biucingcli/template_data/apple/template/scripts/bootstrap +9 -0
  82. biucingcli/template_data/apple/template/scripts/doctor +163 -0
  83. biucingcli/template_data/apple/template/scripts/setup-xcode +6 -0
  84. biucingcli/template_data/apple/template/scripts/test-destination +42 -0
  85. biucingcli/template_data/apple/template/scripts/verify-release-identity +88 -0
  86. biucingcli/template_data/apple/template.json +110 -0
  87. biucingcli/template_data/frontend/template/.dockerignore +8 -0
  88. biucingcli/template_data/frontend/template/.env.example +1 -0
  89. biucingcli/template_data/frontend/template/.gitignore +7 -0
  90. biucingcli/template_data/frontend/template/.npmrc +1 -0
  91. biucingcli/template_data/frontend/template/.prettierignore +2 -0
  92. biucingcli/template_data/frontend/template/.prettierrc.json +4 -0
  93. biucingcli/template_data/frontend/template/Dockerfile +25 -0
  94. biucingcli/template_data/frontend/template/Dockerfile.dev +35 -0
  95. biucingcli/template_data/frontend/template/Dockerfile.dev.full +40 -0
  96. biucingcli/template_data/frontend/template/Makefile +137 -0
  97. biucingcli/template_data/frontend/template/README.md +146 -0
  98. biucingcli/template_data/frontend/template/compose.dev.yaml +29 -0
  99. biucingcli/template_data/frontend/template/eslint.config.js +27 -0
  100. biucingcli/template_data/frontend/template/index.html +12 -0
  101. biucingcli/template_data/frontend/template/nginx.conf +11 -0
  102. biucingcli/template_data/frontend/template/package.json +50 -0
  103. biucingcli/template_data/frontend/template/playwright.production.config.ts +21 -0
  104. biucingcli/template_data/frontend/template/playwright.smoke.config.ts +19 -0
  105. biucingcli/template_data/frontend/template/pnpm-lock.yaml +4054 -0
  106. biucingcli/template_data/frontend/template/public/.gitkeep +1 -0
  107. biucingcli/template_data/frontend/template/scripts/browser-smoke-production +55 -0
  108. biucingcli/template_data/frontend/template/scripts/doctor +46 -0
  109. biucingcli/template_data/frontend/template/src/App.test.tsx +18 -0
  110. biucingcli/template_data/frontend/template/src/App.tsx +5 -0
  111. biucingcli/template_data/frontend/template/src/components/MetricCard.tsx +14 -0
  112. biucingcli/template_data/frontend/template/src/components/TaskPanel.tsx +32 -0
  113. biucingcli/template_data/frontend/template/src/config/env.ts +3 -0
  114. biucingcli/template_data/frontend/template/src/hooks/useProjectOverview.ts +24 -0
  115. biucingcli/template_data/frontend/template/src/index.css +208 -0
  116. biucingcli/template_data/frontend/template/src/main.tsx +11 -0
  117. biucingcli/template_data/frontend/template/src/pages/HomePage.tsx +60 -0
  118. biucingcli/template_data/frontend/template/src/router/AppRouter.tsx +14 -0
  119. biucingcli/template_data/frontend/template/src/services/api/client.ts +33 -0
  120. biucingcli/template_data/frontend/template/src/services/projectOverview.ts +39 -0
  121. biucingcli/template_data/frontend/template/src/test/setup.ts +1 -0
  122. biucingcli/template_data/frontend/template/src/types/projectOverview.ts +22 -0
  123. biucingcli/template_data/frontend/template/src/vite-env.d.ts +9 -0
  124. biucingcli/template_data/frontend/template/tests/browser-smoke.spec.ts +16 -0
  125. biucingcli/template_data/frontend/template/tests/production-browser-smoke.spec.ts +22 -0
  126. biucingcli/template_data/frontend/template/tsconfig.json +21 -0
  127. biucingcli/template_data/frontend/template/vite.config.ts +12 -0
  128. biucingcli/template_data/frontend/template.json +81 -0
  129. biucingcli/template_data/harmonyos/template/.gitignore +21 -0
  130. biucingcli/template_data/harmonyos/template/.mise.toml +2 -0
  131. biucingcli/template_data/harmonyos/template/AppScope/app.json5 +10 -0
  132. biucingcli/template_data/harmonyos/template/AppScope/resources/base/element/string.json +8 -0
  133. biucingcli/template_data/harmonyos/template/AppScope/resources/base/media/background.svg +3 -0
  134. biucingcli/template_data/harmonyos/template/AppScope/resources/base/media/foreground.svg +4 -0
  135. biucingcli/template_data/harmonyos/template/AppScope/resources/base/media/layered_image.json +6 -0
  136. biucingcli/template_data/harmonyos/template/Makefile +106 -0
  137. biucingcli/template_data/harmonyos/template/README.md +152 -0
  138. biucingcli/template_data/harmonyos/template/build-profile.json5 +36 -0
  139. biucingcli/template_data/harmonyos/template/code-linter.json5 +12 -0
  140. biucingcli/template_data/harmonyos/template/docs/release-signing.local.properties.example +14 -0
  141. biucingcli/template_data/harmonyos/template/entry/build-profile.json5 +9 -0
  142. biucingcli/template_data/harmonyos/template/entry/hvigorfile.ts +6 -0
  143. biucingcli/template_data/harmonyos/template/entry/oh-package.json5 +9 -0
  144. biucingcli/template_data/harmonyos/template/entry/src/main/ets/core/config/AppConfig.ets +10 -0
  145. biucingcli/template_data/harmonyos/template/entry/src/main/ets/core/designsystem/Tokens.ets +28 -0
  146. biucingcli/template_data/harmonyos/template/entry/src/main/ets/entryability/EntryAbility.ets +29 -0
  147. biucingcli/template_data/harmonyos/template/entry/src/main/ets/pages/Index.ets +47 -0
  148. biucingcli/template_data/harmonyos/template/entry/src/main/ets/pages/Settings.ets +96 -0
  149. biucingcli/template_data/harmonyos/template/entry/src/main/module.json5 +34 -0
  150. biucingcli/template_data/harmonyos/template/entry/src/main/resources/base/element/color.json +24 -0
  151. biucingcli/template_data/harmonyos/template/entry/src/main/resources/base/element/string.json +12 -0
  152. biucingcli/template_data/harmonyos/template/entry/src/main/resources/base/media/app_icon.svg +5 -0
  153. biucingcli/template_data/harmonyos/template/entry/src/main/resources/base/profile/main_pages.json +6 -0
  154. biucingcli/template_data/harmonyos/template/entry/src/test/List.test.ets +11 -0
  155. biucingcli/template_data/harmonyos/template/hvigor/hvigor-config.json5 +8 -0
  156. biucingcli/template_data/harmonyos/template/hvigorfile.ts +6 -0
  157. biucingcli/template_data/harmonyos/template/oh-package-lock.json5 +19 -0
  158. biucingcli/template_data/harmonyos/template/oh-package.json5 +13 -0
  159. biucingcli/template_data/harmonyos/template/scripts/artifact-info +31 -0
  160. biucingcli/template_data/harmonyos/template/scripts/bootstrap +38 -0
  161. biucingcli/template_data/harmonyos/template/scripts/doctor +147 -0
  162. biucingcli/template_data/harmonyos/template/scripts/lint +105 -0
  163. biucingcli/template_data/harmonyos/template/scripts/release-build +199 -0
  164. biucingcli/template_data/harmonyos/template/scripts/release-preflight +109 -0
  165. biucingcli/template_data/harmonyos/template/scripts/test +28 -0
  166. biucingcli/template_data/harmonyos/template/scripts/verify-release-artifact +173 -0
  167. biucingcli/template_data/harmonyos/template/scripts/verify-supply-chain +70 -0
  168. biucingcli/template_data/harmonyos/template.json +134 -0
  169. biucingcli/template_data/microservice/template/.air.toml +11 -0
  170. biucingcli/template_data/microservice/template/.dockerignore +5 -0
  171. biucingcli/template_data/microservice/template/.gitignore +4 -0
  172. biucingcli/template_data/microservice/template/.mise.toml +3 -0
  173. biucingcli/template_data/microservice/template/Brewfile +7 -0
  174. biucingcli/template_data/microservice/template/Dockerfile +44 -0
  175. biucingcli/template_data/microservice/template/Dockerfile.dev +50 -0
  176. biucingcli/template_data/microservice/template/Makefile +145 -0
  177. biucingcli/template_data/microservice/template/README.md +191 -0
  178. biucingcli/template_data/microservice/template/api/buf.gen.yaml +11 -0
  179. biucingcli/template_data/microservice/template/api/buf.yaml +11 -0
  180. biucingcli/template_data/microservice/template/api/proto/service/v1/service.proto +18 -0
  181. biucingcli/template_data/microservice/template/cmd/server/main.go +81 -0
  182. biucingcli/template_data/microservice/template/compose.dev.yaml +49 -0
  183. biucingcli/template_data/microservice/template/configs/config.yaml +18 -0
  184. biucingcli/template_data/microservice/template/deploy/compose.yaml +35 -0
  185. biucingcli/template_data/microservice/template/deploy/otel-collector.yaml +15 -0
  186. biucingcli/template_data/microservice/template/go.mod +53 -0
  187. biucingcli/template_data/microservice/template/go.sum +138 -0
  188. biucingcli/template_data/microservice/template/internal/config/config.go +112 -0
  189. biucingcli/template_data/microservice/template/internal/config/config_test.go +92 -0
  190. biucingcli/template_data/microservice/template/internal/handler/health.go +25 -0
  191. biucingcli/template_data/microservice/template/internal/handler/ping.go +25 -0
  192. biucingcli/template_data/microservice/template/internal/model/health.go +8 -0
  193. biucingcli/template_data/microservice/template/internal/model/ping.go +7 -0
  194. biucingcli/template_data/microservice/template/internal/repository/.gitkeep +1 -0
  195. biucingcli/template_data/microservice/template/internal/router/router.go +26 -0
  196. biucingcli/template_data/microservice/template/internal/runtime/server.go +116 -0
  197. biucingcli/template_data/microservice/template/internal/runtime/server_test.go +161 -0
  198. biucingcli/template_data/microservice/template/internal/service/health.go +26 -0
  199. biucingcli/template_data/microservice/template/internal/service/ping.go +23 -0
  200. biucingcli/template_data/microservice/template/internal/telemetry/telemetry.go +56 -0
  201. biucingcli/template_data/microservice/template/internal/transport/grpc.go +51 -0
  202. biucingcli/template_data/microservice/template/internal/transport/ping.go +28 -0
  203. biucingcli/template_data/microservice/template/scripts/bootstrap +29 -0
  204. biucingcli/template_data/microservice/template/scripts/doctor +115 -0
  205. biucingcli/template_data/microservice/template/tests/server_test.go +153 -0
  206. biucingcli/template_data/microservice/template.json +114 -0
  207. biucingcli/template_data/web-service/template/.air.toml +11 -0
  208. biucingcli/template_data/web-service/template/.dockerignore +5 -0
  209. biucingcli/template_data/web-service/template/.gitignore +5 -0
  210. biucingcli/template_data/web-service/template/.mise.toml +2 -0
  211. biucingcli/template_data/web-service/template/Brewfile +5 -0
  212. biucingcli/template_data/web-service/template/Dockerfile +41 -0
  213. biucingcli/template_data/web-service/template/Dockerfile.dev +45 -0
  214. biucingcli/template_data/web-service/template/Makefile +113 -0
  215. biucingcli/template_data/web-service/template/README.md +164 -0
  216. biucingcli/template_data/web-service/template/cmd/server/main.go +50 -0
  217. biucingcli/template_data/web-service/template/compose.dev.yaml +28 -0
  218. biucingcli/template_data/web-service/template/compose.yaml +14 -0
  219. biucingcli/template_data/web-service/template/configs/config.yaml +10 -0
  220. biucingcli/template_data/web-service/template/go.mod +36 -0
  221. biucingcli/template_data/web-service/template/go.sum +89 -0
  222. biucingcli/template_data/web-service/template/internal/config/config.go +84 -0
  223. biucingcli/template_data/web-service/template/internal/config/config_test.go +88 -0
  224. biucingcli/template_data/web-service/template/internal/handler/health.go +25 -0
  225. biucingcli/template_data/web-service/template/internal/handler/ping.go +25 -0
  226. biucingcli/template_data/web-service/template/internal/handler/user.go +40 -0
  227. biucingcli/template_data/web-service/template/internal/model/health.go +6 -0
  228. biucingcli/template_data/web-service/template/internal/model/ping.go +7 -0
  229. biucingcli/template_data/web-service/template/internal/model/user.go +7 -0
  230. biucingcli/template_data/web-service/template/internal/repository/.gitkeep +1 -0
  231. biucingcli/template_data/web-service/template/internal/repository/user.go +37 -0
  232. biucingcli/template_data/web-service/template/internal/router/router.go +28 -0
  233. biucingcli/template_data/web-service/template/internal/runtime/server.go +76 -0
  234. biucingcli/template_data/web-service/template/internal/runtime/server_test.go +139 -0
  235. biucingcli/template_data/web-service/template/internal/service/health.go +22 -0
  236. biucingcli/template_data/web-service/template/internal/service/ping.go +23 -0
  237. biucingcli/template_data/web-service/template/internal/service/user.go +27 -0
  238. biucingcli/template_data/web-service/template/scripts/bootstrap +23 -0
  239. biucingcli/template_data/web-service/template/scripts/doctor +83 -0
  240. biucingcli/template_data/web-service/template/tests/server_test.go +160 -0
  241. biucingcli/template_data/web-service/template.json +88 -0
  242. biucingcli/template_data/worker/template/.dockerignore +3 -0
  243. biucingcli/template_data/worker/template/.gitignore +2 -0
  244. biucingcli/template_data/worker/template/.mise.toml +2 -0
  245. biucingcli/template_data/worker/template/Brewfile +1 -0
  246. biucingcli/template_data/worker/template/Dockerfile +19 -0
  247. biucingcli/template_data/worker/template/Dockerfile.dev +9 -0
  248. biucingcli/template_data/worker/template/Makefile +105 -0
  249. biucingcli/template_data/worker/template/README.md +164 -0
  250. biucingcli/template_data/worker/template/cmd/worker/main.go +41 -0
  251. biucingcli/template_data/worker/template/compose.dev.yaml +29 -0
  252. biucingcli/template_data/worker/template/configs/config.json +11 -0
  253. biucingcli/template_data/worker/template/go.mod +3 -0
  254. biucingcli/template_data/worker/template/go.sum +1 -0
  255. biucingcli/template_data/worker/template/internal/config/config.go +108 -0
  256. biucingcli/template_data/worker/template/internal/config/config_test.go +86 -0
  257. biucingcli/template_data/worker/template/internal/runtime/runner.go +199 -0
  258. biucingcli/template_data/worker/template/internal/runtime/runner_test.go +215 -0
  259. biucingcli/template_data/worker/template/internal/task/heartbeat.go +19 -0
  260. biucingcli/template_data/worker/template/scripts/bootstrap +6 -0
  261. biucingcli/template_data/worker/template/scripts/doctor +41 -0
  262. biucingcli/template_data/worker/template/tests/worker_test.go +44 -0
  263. biucingcli/template_data/worker/template.json +100 -0
  264. biucingcli/templates.py +902 -0
  265. biucingcli-0.9.1.dist-info/METADATA +204 -0
  266. biucingcli-0.9.1.dist-info/RECORD +269 -0
  267. biucingcli-0.9.1.dist-info/WHEEL +5 -0
  268. biucingcli-0.9.1.dist-info/entry_points.txt +2 -0
  269. biucingcli-0.9.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,81 @@
1
+ package main
2
+
3
+ import (
4
+ "context"
5
+ "log"
6
+ "net"
7
+ "os"
8
+ "os/signal"
9
+ "syscall"
10
+ "time"
11
+
12
+ "{{MODULE_NAME}}/internal/config"
13
+ "{{MODULE_NAME}}/internal/router"
14
+ serverruntime "{{MODULE_NAME}}/internal/runtime"
15
+ "{{MODULE_NAME}}/internal/service"
16
+ "{{MODULE_NAME}}/internal/telemetry"
17
+ "{{MODULE_NAME}}/internal/transport"
18
+ )
19
+
20
+ func main() {
21
+ if len(os.Args) == 3 && os.Args[1] == "healthcheck" {
22
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
23
+ defer cancel()
24
+ if err := serverruntime.CheckHealth(ctx, os.Args[2]); err != nil {
25
+ log.Fatal(err)
26
+ }
27
+ return
28
+ }
29
+
30
+ cfg, err := config.Load()
31
+ if err != nil {
32
+ log.Fatal(err)
33
+ }
34
+
35
+ shutdown, telemetryErr := telemetry.Setup(
36
+ context.Background(),
37
+ cfg.Service.Name,
38
+ cfg.Telemetry.OTLPHTTPEndpoint,
39
+ )
40
+ if telemetryErr != nil {
41
+ log.Printf("telemetry setup warning: %v", telemetryErr)
42
+ }
43
+ grpcListener, err := net.Listen("tcp", ":"+cfg.Service.GRPCPort)
44
+ if err != nil {
45
+ log.Fatal(err)
46
+ }
47
+
48
+ httpListener, err := net.Listen("tcp", ":"+cfg.Service.HTTPPort)
49
+ if err != nil {
50
+ _ = grpcListener.Close()
51
+ log.Fatal(err)
52
+ }
53
+
54
+ pingService := service.NewPingService(cfg.Service.Name, "{{PROTO_PACKAGE}}")
55
+ grpcServer := transport.NewGRPCServer(cfg.Service.Name, pingService)
56
+ httpServer := serverruntime.NewHTTPServer(cfg, router.New(cfg))
57
+
58
+ ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
59
+ defer stop()
60
+
61
+ log.Printf("starting %s gRPC server on :%s", cfg.Service.Name, cfg.Service.GRPCPort)
62
+ log.Printf("starting %s HTTP server on :%s", cfg.Service.Name, cfg.Service.HTTPPort)
63
+ shutdownTimeout := time.Duration(cfg.Server.ShutdownTimeoutSeconds) * time.Second
64
+ serveErr := serverruntime.Serve(
65
+ ctx,
66
+ httpServer,
67
+ httpListener,
68
+ grpcServer,
69
+ grpcListener,
70
+ shutdownTimeout,
71
+ )
72
+
73
+ telemetryCtx, cancelTelemetry := context.WithTimeout(context.Background(), shutdownTimeout)
74
+ defer cancelTelemetry()
75
+ if err := shutdown(telemetryCtx); err != nil {
76
+ log.Printf("telemetry shutdown warning: %v", err)
77
+ }
78
+ if serveErr != nil {
79
+ log.Fatal(serveErr)
80
+ }
81
+ }
@@ -0,0 +1,49 @@
1
+ services:
2
+ app-dev:
3
+ build:
4
+ context: .
5
+ dockerfile: Dockerfile.dev
6
+ args:
7
+ GOPROXY: ${GOPROXY:-https://proxy.golang.org,direct}
8
+ GOSUMDB: ${GOSUMDB:-sum.golang.org}
9
+ working_dir: /workspace
10
+ command: air -c .air.toml
11
+ environment:
12
+ CONFIG_FILE: /workspace/configs/config.yaml
13
+ GOCACHE: /workspace/.cache/go-build
14
+ GOMODCACHE: /workspace/.cache/go-mod
15
+ GOLANGCI_LINT_CACHE: /workspace/.cache/golangci-lint
16
+ OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
17
+ STORE_DSN: {{DEPENDENCY_STORE_CONTAINER_DSN}}
18
+ depends_on:
19
+ - {{DEPENDENCY_STORE}}
20
+ - otel-collector
21
+ ports:
22
+ - "${HOST_HTTP_PORT:-{{HTTP_PORT}}}:{{HTTP_PORT}}"
23
+ - "${HOST_GRPC_PORT:-{{GRPC_PORT}}}:{{GRPC_PORT}}"
24
+ stop_grace_period: 15s
25
+ volumes:
26
+ - .:/workspace
27
+ - microservice-go-build:/workspace/.cache/go-build
28
+ - microservice-go-mod:/workspace/.cache/go-mod
29
+ - microservice-golangci-lint:/workspace/.cache/golangci-lint
30
+
31
+ {{DEPENDENCY_STORE}}:
32
+ image: {{DEPENDENCY_STORE_IMAGE}}
33
+ {{DEPENDENCY_STORE_ENV_BLOCK}}
34
+ ports:
35
+ - "${HOST_DEPENDENCY_STORE_PORT:-{{DEPENDENCY_STORE_PORT}}}:{{DEPENDENCY_STORE_PORT}}"
36
+
37
+ otel-collector:
38
+ image: otel/opentelemetry-collector-contrib:0.126.0
39
+ command: ["--config=/etc/otelcol-contrib/config.yaml"]
40
+ volumes:
41
+ - ./deploy/otel-collector.yaml:/etc/otelcol-contrib/config.yaml:ro
42
+ ports:
43
+ - "${HOST_OTEL_GRPC_PORT:-4317}:4317"
44
+ - "${HOST_OTEL_HTTP_PORT:-4318}:4318"
45
+
46
+ volumes:
47
+ microservice-go-build:
48
+ microservice-go-mod:
49
+ microservice-golangci-lint:
@@ -0,0 +1,18 @@
1
+ service:
2
+ name: {{SERVICE_NAME}}
3
+ http_port: {{HTTP_PORT}}
4
+ grpc_port: {{GRPC_PORT}}
5
+
6
+ server:
7
+ read_timeout_seconds: 5
8
+ read_header_timeout_seconds: 5
9
+ write_timeout_seconds: 15
10
+ idle_timeout_seconds: 60
11
+ shutdown_timeout_seconds: 10
12
+
13
+ telemetry:
14
+ otlp_http_endpoint: {{OTEL_EXPORTER_ENDPOINT}}
15
+
16
+ store:
17
+ driver: {{DEPENDENCY_STORE}}
18
+ dsn: {{DEPENDENCY_STORE_DSN}}
@@ -0,0 +1,35 @@
1
+ services:
2
+ {{SERVICE_NAME}}:
3
+ build:
4
+ context: ..
5
+ dockerfile: Dockerfile
6
+ args:
7
+ BUILDER_IMAGE: ${BUILDER_IMAGE:-golang:1.26-alpine}
8
+ RUNTIME_IMAGE: ${RUNTIME_IMAGE:-alpine:3.20}
9
+ image: ${IMAGE:-{{SERVICE_NAME}}}:${TAG:-latest}
10
+ ports:
11
+ - "${HOST_HTTP_PORT:-{{HTTP_PORT}}}:{{HTTP_PORT}}"
12
+ - "${HOST_GRPC_PORT:-{{GRPC_PORT}}}:{{GRPC_PORT}}"
13
+ environment:
14
+ CONFIG_FILE: /app/configs/config.yaml
15
+ OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
16
+ STORE_DSN: {{DEPENDENCY_STORE_CONTAINER_DSN}}
17
+ depends_on:
18
+ - {{DEPENDENCY_STORE}}
19
+ - otel-collector
20
+ stop_grace_period: 15s
21
+
22
+ {{DEPENDENCY_STORE}}:
23
+ image: {{DEPENDENCY_STORE_IMAGE}}
24
+ {{DEPENDENCY_STORE_ENV_BLOCK}}
25
+ ports:
26
+ - "${HOST_DEPENDENCY_STORE_PORT:-{{DEPENDENCY_STORE_PORT}}}:{{DEPENDENCY_STORE_PORT}}"
27
+
28
+ otel-collector:
29
+ image: otel/opentelemetry-collector-contrib:latest
30
+ command: ["--config=/etc/otelcol-contrib/config.yaml"]
31
+ volumes:
32
+ - ./otel-collector.yaml:/etc/otelcol-contrib/config.yaml:ro
33
+ ports:
34
+ - "${HOST_OTEL_GRPC_PORT:-4317}:4317"
35
+ - "${HOST_OTEL_HTTP_PORT:-4318}:4318"
@@ -0,0 +1,15 @@
1
+ receivers:
2
+ otlp:
3
+ protocols:
4
+ grpc:
5
+ http:
6
+
7
+ exporters:
8
+ debug:
9
+ verbosity: normal
10
+
11
+ service:
12
+ pipelines:
13
+ traces:
14
+ receivers: [otlp]
15
+ exporters: [debug]
@@ -0,0 +1,53 @@
1
+ module {{MODULE_NAME}}
2
+
3
+ go 1.26.0
4
+
5
+ require (
6
+ github.com/gin-gonic/gin v1.10.0
7
+ go.opentelemetry.io/otel v1.43.0
8
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0
9
+ go.opentelemetry.io/otel/sdk v1.43.0
10
+ google.golang.org/grpc v1.81.1
11
+ gopkg.in/yaml.v3 v3.0.1
12
+ )
13
+
14
+ require (
15
+ github.com/bytedance/sonic v1.11.6 // indirect
16
+ github.com/bytedance/sonic/loader v0.1.1 // indirect
17
+ github.com/cenkalti/backoff/v5 v5.0.3 // indirect
18
+ github.com/cespare/xxhash/v2 v2.3.0 // indirect
19
+ github.com/cloudwego/base64x v0.1.4 // indirect
20
+ github.com/cloudwego/iasm v0.2.0 // indirect
21
+ github.com/gabriel-vasile/mimetype v1.4.3 // indirect
22
+ github.com/gin-contrib/sse v0.1.0 // indirect
23
+ github.com/go-logr/logr v1.4.3 // indirect
24
+ github.com/go-logr/stdr v1.2.2 // indirect
25
+ github.com/go-playground/locales v0.14.1 // indirect
26
+ github.com/go-playground/universal-translator v0.18.1 // indirect
27
+ github.com/go-playground/validator/v10 v10.20.0 // indirect
28
+ github.com/goccy/go-json v0.10.2 // indirect
29
+ github.com/google/uuid v1.6.0 // indirect
30
+ github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
31
+ github.com/json-iterator/go v1.1.12 // indirect
32
+ github.com/klauspost/cpuid/v2 v2.2.7 // indirect
33
+ github.com/leodido/go-urn v1.4.0 // indirect
34
+ github.com/mattn/go-isatty v0.0.20 // indirect
35
+ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
36
+ github.com/modern-go/reflect2 v1.0.2 // indirect
37
+ github.com/pelletier/go-toml/v2 v2.2.2 // indirect
38
+ github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
39
+ github.com/ugorji/go/codec v1.2.12 // indirect
40
+ go.opentelemetry.io/auto/sdk v1.2.1 // indirect
41
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect
42
+ go.opentelemetry.io/otel/metric v1.43.0 // indirect
43
+ go.opentelemetry.io/otel/trace v1.43.0 // indirect
44
+ go.opentelemetry.io/proto/otlp v1.10.0 // indirect
45
+ golang.org/x/arch v0.8.0 // indirect
46
+ golang.org/x/crypto v0.49.0 // indirect
47
+ golang.org/x/net v0.52.0 // indirect
48
+ golang.org/x/sys v0.42.0 // indirect
49
+ golang.org/x/text v0.35.0 // indirect
50
+ google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
51
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
52
+ google.golang.org/protobuf v1.36.11 // indirect
53
+ )
@@ -0,0 +1,138 @@
1
+ github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
2
+ github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
3
+ github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
4
+ github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
5
+ github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
6
+ github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
7
+ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
8
+ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
9
+ github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
10
+ github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
11
+ github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
12
+ github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
13
+ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
14
+ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
15
+ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
16
+ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
17
+ github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
18
+ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
19
+ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
20
+ github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
21
+ github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
22
+ github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
23
+ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
24
+ github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
25
+ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
26
+ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
27
+ github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
28
+ github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
29
+ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
30
+ github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
31
+ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
32
+ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
33
+ github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
34
+ github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
35
+ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
36
+ github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
37
+ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
38
+ github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
39
+ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
40
+ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
41
+ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
42
+ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
43
+ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
44
+ github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz+PMpZ14Jynv3O2Zs=
45
+ github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0/go.mod h1:JfhWUomR1baixubs02l85lZYYOm7LV6om4ceouMv45c=
46
+ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
47
+ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
48
+ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
49
+ github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
50
+ github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
51
+ github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
52
+ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
53
+ github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
54
+ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
55
+ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
56
+ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
57
+ github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
58
+ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
59
+ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
60
+ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
61
+ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
62
+ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
63
+ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
64
+ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
65
+ github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
66
+ github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
67
+ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
68
+ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
69
+ github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
70
+ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
71
+ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
72
+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
73
+ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
74
+ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
75
+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
76
+ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
77
+ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
78
+ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
79
+ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
80
+ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
81
+ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
82
+ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
83
+ github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
84
+ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
85
+ github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
86
+ github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
87
+ github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
88
+ go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
89
+ go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
90
+ go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
91
+ go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
92
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 h1:88Y4s2C8oTui1LGM6bTWkw0ICGcOLCAI5l6zsD1j20k=
93
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0/go.mod h1:Vl1/iaggsuRlrHf/hfPJPvVag77kKyvrLeD10kpMl+A=
94
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 h1:3iZJKlCZufyRzPzlQhUIWVmfltrXuGyfjREgGP3UUjc=
95
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0/go.mod h1:/G+nUPfhq2e+qiXMGxMwumDrP5jtzU+mWN7/sjT2rak=
96
+ go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
97
+ go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
98
+ go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=
99
+ go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg=
100
+ go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw=
101
+ go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=
102
+ go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
103
+ go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
104
+ go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
105
+ go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
106
+ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
107
+ go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
108
+ golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
109
+ golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
110
+ golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
111
+ golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
112
+ golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
113
+ golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
114
+ golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
115
+ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
116
+ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
117
+ golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
118
+ golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
119
+ golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
120
+ golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
121
+ gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
122
+ gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
123
+ google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 h1:VPWxll4HlMw1Vs/qXtN7BvhZqsS9cdAittCNvVENElA=
124
+ google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:7QBABkRtR8z+TEnmXTqIqwJLlzrZKVfAUm7tY3yGv0M=
125
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 h1:m8qni9SQFH0tJc1X0vmnpw/0t+AImlSvp30sEupozUg=
126
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
127
+ google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ=
128
+ google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
129
+ google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
130
+ google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
131
+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
132
+ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
133
+ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
134
+ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
135
+ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
136
+ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
137
+ nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
138
+ rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
@@ -0,0 +1,112 @@
1
+ package config
2
+
3
+ import (
4
+ "errors"
5
+ "os"
6
+
7
+ "gopkg.in/yaml.v3"
8
+ )
9
+
10
+ const defaultConfigFile = "configs/config.yaml"
11
+
12
+ type Config struct {
13
+ Service ServiceConfig `yaml:"service"`
14
+ Server ServerConfig `yaml:"server"`
15
+ Telemetry TelemetryConfig `yaml:"telemetry"`
16
+ Store StoreConfig `yaml:"store"`
17
+ }
18
+
19
+ type ServerConfig struct {
20
+ ReadTimeoutSeconds int `yaml:"read_timeout_seconds"`
21
+ ReadHeaderTimeoutSeconds int `yaml:"read_header_timeout_seconds"`
22
+ WriteTimeoutSeconds int `yaml:"write_timeout_seconds"`
23
+ IdleTimeoutSeconds int `yaml:"idle_timeout_seconds"`
24
+ ShutdownTimeoutSeconds int `yaml:"shutdown_timeout_seconds"`
25
+ }
26
+
27
+ type ServiceConfig struct {
28
+ Name string `yaml:"name"`
29
+ HTTPPort string `yaml:"http_port"`
30
+ GRPCPort string `yaml:"grpc_port"`
31
+ }
32
+
33
+ type TelemetryConfig struct {
34
+ OTLPHTTPEndpoint string `yaml:"otlp_http_endpoint"`
35
+ }
36
+
37
+ type StoreConfig struct {
38
+ Driver string `yaml:"driver"`
39
+ DSN string `yaml:"dsn"`
40
+ }
41
+
42
+ func Load() (Config, error) {
43
+ configFile := os.Getenv("CONFIG_FILE")
44
+ if configFile == "" {
45
+ configFile = defaultConfigFile
46
+ }
47
+
48
+ data, err := os.ReadFile(configFile)
49
+ if err != nil {
50
+ return Config{}, err
51
+ }
52
+
53
+ var cfg Config
54
+ if err := yaml.Unmarshal(data, &cfg); err != nil {
55
+ return Config{}, err
56
+ }
57
+
58
+ if cfg.Service.Name == "" {
59
+ return Config{}, errors.New("service.name is required")
60
+ }
61
+ if cfg.Service.HTTPPort == "" {
62
+ cfg.Service.HTTPPort = "{{HTTP_PORT}}"
63
+ }
64
+ if cfg.Service.GRPCPort == "" {
65
+ cfg.Service.GRPCPort = "{{GRPC_PORT}}"
66
+ }
67
+ if err := cfg.Server.applyDefaults(); err != nil {
68
+ return Config{}, err
69
+ }
70
+ if cfg.Store.Driver == "" {
71
+ cfg.Store.Driver = "{{DEPENDENCY_STORE}}"
72
+ }
73
+ if cfg.Store.DSN == "" {
74
+ cfg.Store.DSN = "{{DEPENDENCY_STORE_DSN}}"
75
+ }
76
+ if override := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT"); override != "" {
77
+ cfg.Telemetry.OTLPHTTPEndpoint = override
78
+ }
79
+ if cfg.Telemetry.OTLPHTTPEndpoint == "" {
80
+ cfg.Telemetry.OTLPHTTPEndpoint = "{{OTEL_EXPORTER_ENDPOINT}}"
81
+ }
82
+ if override := os.Getenv("STORE_DSN"); override != "" {
83
+ cfg.Store.DSN = override
84
+ }
85
+
86
+ return cfg, nil
87
+ }
88
+
89
+ func (cfg *ServerConfig) applyDefaults() error {
90
+ values := []struct {
91
+ name string
92
+ value *int
93
+ defaultValue int
94
+ }{
95
+ {"server.read_timeout_seconds", &cfg.ReadTimeoutSeconds, 5},
96
+ {"server.read_header_timeout_seconds", &cfg.ReadHeaderTimeoutSeconds, 5},
97
+ {"server.write_timeout_seconds", &cfg.WriteTimeoutSeconds, 15},
98
+ {"server.idle_timeout_seconds", &cfg.IdleTimeoutSeconds, 60},
99
+ {"server.shutdown_timeout_seconds", &cfg.ShutdownTimeoutSeconds, 10},
100
+ }
101
+
102
+ for _, item := range values {
103
+ if *item.value < 0 {
104
+ return errors.New(item.name + " must be greater than zero")
105
+ }
106
+ if *item.value == 0 {
107
+ *item.value = item.defaultValue
108
+ }
109
+ }
110
+
111
+ return nil
112
+ }
@@ -0,0 +1,92 @@
1
+ package config
2
+
3
+ import (
4
+ "os"
5
+ "path/filepath"
6
+ "testing"
7
+ )
8
+
9
+ func TestLoadDefaultConfig(t *testing.T) {
10
+ tempDir := t.TempDir()
11
+ configDir := filepath.Join(tempDir, "configs")
12
+ if err := os.MkdirAll(configDir, 0o755); err != nil {
13
+ t.Fatal(err)
14
+ }
15
+
16
+ configFile := filepath.Join(configDir, "config.yaml")
17
+ if err := os.WriteFile(
18
+ configFile,
19
+ []byte("service:\n name: demo\n http_port: 8080\n grpc_port: 9090\ntelemetry:\n otlp_http_endpoint: http://localhost:4318\nstore:\n driver: postgres\n dsn: postgres://postgres:postgres@localhost:5432/demo?sslmode=disable\n"),
20
+ 0o644,
21
+ ); err != nil {
22
+ t.Fatal(err)
23
+ }
24
+
25
+ t.Setenv("CONFIG_FILE", configFile)
26
+ cfg, err := Load()
27
+ if err != nil {
28
+ t.Fatal(err)
29
+ }
30
+
31
+ if cfg.Service.Name != "demo" {
32
+ t.Fatalf("expected service name %q, got %q", "demo", cfg.Service.Name)
33
+ }
34
+ if cfg.Service.GRPCPort != "9090" {
35
+ t.Fatalf("expected gRPC port %q, got %q", "9090", cfg.Service.GRPCPort)
36
+ }
37
+ if cfg.Server.ShutdownTimeoutSeconds != 10 {
38
+ t.Fatalf("expected default shutdown timeout %d, got %d", 10, cfg.Server.ShutdownTimeoutSeconds)
39
+ }
40
+ }
41
+
42
+ func TestLoadRejectsNegativeTimeout(t *testing.T) {
43
+ configFile := filepath.Join(t.TempDir(), "invalid.yaml")
44
+ if err := os.WriteFile(
45
+ configFile,
46
+ []byte("service:\n name: demo\nserver:\n read_timeout_seconds: -1\n"),
47
+ 0o644,
48
+ ); err != nil {
49
+ t.Fatal(err)
50
+ }
51
+ t.Setenv("CONFIG_FILE", configFile)
52
+
53
+ if _, err := Load(); err == nil {
54
+ t.Fatal("expected a negative timeout to fail validation")
55
+ }
56
+ }
57
+
58
+ func TestLoadUsesEnvironmentOverrides(t *testing.T) {
59
+ tempDir := t.TempDir()
60
+ configDir := filepath.Join(tempDir, "configs")
61
+ if err := os.MkdirAll(configDir, 0o755); err != nil {
62
+ t.Fatal(err)
63
+ }
64
+
65
+ configFile := filepath.Join(configDir, "config.yaml")
66
+ if err := os.WriteFile(
67
+ configFile,
68
+ []byte("service:\n name: demo\ntelemetry:\n otlp_http_endpoint: http://localhost:4318\nstore:\n driver: redis\n dsn: redis://localhost:6379/0\n"),
69
+ 0o644,
70
+ ); err != nil {
71
+ t.Fatal(err)
72
+ }
73
+
74
+ t.Setenv("CONFIG_FILE", configFile)
75
+ t.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://otel-collector:4318")
76
+ t.Setenv("STORE_DSN", "redis://redis:6379/0")
77
+
78
+ cfg, err := Load()
79
+ if err != nil {
80
+ t.Fatal(err)
81
+ }
82
+
83
+ if cfg.Service.HTTPPort != "{{HTTP_PORT}}" {
84
+ t.Fatalf("expected default HTTP port %q, got %q", "{{HTTP_PORT}}", cfg.Service.HTTPPort)
85
+ }
86
+ if cfg.Telemetry.OTLPHTTPEndpoint != "http://otel-collector:4318" {
87
+ t.Fatalf("expected telemetry endpoint override, got %q", cfg.Telemetry.OTLPHTTPEndpoint)
88
+ }
89
+ if cfg.Store.DSN != "redis://redis:6379/0" {
90
+ t.Fatalf("expected store override, got %q", cfg.Store.DSN)
91
+ }
92
+ }
@@ -0,0 +1,25 @@
1
+ package handler
2
+
3
+ import (
4
+ "net/http"
5
+
6
+ "{{MODULE_NAME}}/internal/service"
7
+
8
+ "github.com/gin-gonic/gin"
9
+ )
10
+
11
+ type HealthHandler struct {
12
+ service service.HealthService
13
+ }
14
+
15
+ func NewHealthHandler(service service.HealthService) HealthHandler {
16
+ return HealthHandler{service: service}
17
+ }
18
+
19
+ func (handler HealthHandler) RegisterRoutes(engine *gin.Engine) {
20
+ engine.GET("/healthz", handler.handleHealthz)
21
+ }
22
+
23
+ func (handler HealthHandler) handleHealthz(context *gin.Context) {
24
+ context.JSON(http.StatusOK, handler.service.Status())
25
+ }
@@ -0,0 +1,25 @@
1
+ package handler
2
+
3
+ import (
4
+ "net/http"
5
+
6
+ "{{MODULE_NAME}}/internal/service"
7
+
8
+ "github.com/gin-gonic/gin"
9
+ )
10
+
11
+ type PingHandler struct {
12
+ service service.PingService
13
+ }
14
+
15
+ func NewPingHandler(service service.PingService) PingHandler {
16
+ return PingHandler{service: service}
17
+ }
18
+
19
+ func (handler PingHandler) RegisterRoutes(group *gin.RouterGroup) {
20
+ group.GET("/ping", handler.handlePing)
21
+ }
22
+
23
+ func (handler PingHandler) handlePing(context *gin.Context) {
24
+ context.JSON(http.StatusOK, handler.service.Ping())
25
+ }
@@ -0,0 +1,8 @@
1
+ package model
2
+
3
+ type HealthResponse struct {
4
+ Service string `json:"service"`
5
+ Status string `json:"status"`
6
+ Store string `json:"store"`
7
+ GRPCPort string `json:"grpcPort"`
8
+ }
@@ -0,0 +1,7 @@
1
+ package model
2
+
3
+ type PingResponse struct {
4
+ Message string `json:"message"`
5
+ Service string `json:"service"`
6
+ ProtoPackage string `json:"protoPackage"`
7
+ }