<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Microservices on seth-shi</title><link>https://sethix.com/tags/microservices/</link><description>Recent content in Microservices on seth-shi</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Tue, 24 Oct 2023 15:49:25 +0800</lastBuildDate><atom:link href="https://sethix.com/tags/microservices/index.xml" rel="self" type="application/rss+xml"/><item><title>Using gorm gen in go-zero</title><link>https://sethix.com/posts/2023102415/</link><pubDate>Tue, 24 Oct 2023 15:49:25 +0800</pubDate><guid>https://sethix.com/posts/2023102415/</guid><description>Since the built-in sqlx in go-zero is too cumbersome to use, and it&amp;rsquo;s unbearable to write so many magic strings, this article introduces how to integrate gorm into go-zero.
Code Implementation // cmd/gen.go package main import ( &amp;#34;fmt&amp;#34; &amp;#34;path&amp;#34; &amp;#34;gorm.io/driver/mysql&amp;#34; &amp;#34;gorm.io/gen&amp;#34; &amp;#34;gorm.io/gen/field&amp;#34; &amp;#34;gorm.io/gorm&amp;#34; ) var ( // Modify these when generating for other services mysqlDsn = &amp;#34;xxx:xxx@tcp(127.0.0.1:3306)/xxx?charset=utf8mb4&amp;amp;loc=Local&amp;amp;parseTime=true&amp;#34; outPath = path.Join(&amp;#34;..&amp;#34;, &amp;#34;app&amp;#34;, &amp;#34;account&amp;#34;, &amp;#34;model&amp;#34;, &amp;#34;do&amp;#34;) modelPath = &amp;#34;entity&amp;#34; ) func main() { db, err := gorm.</description></item><item><title>Using gRPC Client for System Login in PHP Backend dcat-admin</title><link>https://sethix.com/posts/2023102010/</link><pubDate>Fri, 20 Oct 2023 10:38:05 +0800</pubDate><guid>https://sethix.com/posts/2023102010/</guid><description>Introduction The company has implemented a unified account center service using go-zero Some project backends built with dcat-admin need to authenticate users through this account center, documenting the implementation process Environment Setup Protobuf binary files from https://github.com/protocolbuffers/protobuf/releases Follow official documentation for installation: https://cloud.google.com/php/grpc?hl=zh-cn#windows For Windows: Download corresponding PHP version DLL from https://pecl.php.net/package/grpc Install packages: composer require &amp;#34;grpc/grpc:^1.38&amp;#34; composer require &amp;#34;google/protobuf:^3.17&amp;#34; For Docker (using mlocati/docker-php-extension-installer): RUN install-php-extensions grpc Generate PHP gRPC code requires grpc_php_plugin: Official guide: https://github.</description></item><item><title>Why Are 0.5-Core Pods on k8s So Busy?</title><link>https://sethix.com/posts/2023091320/</link><pubDate>Wed, 13 Sep 2023 20:05:42 +0800</pubDate><guid>https://sethix.com/posts/2023091320/</guid><description>Context Our CTO mentioned during a code review that our services run on 0.5-core Kubernetes pods and advised adjusting runtime parameters. Here&amp;rsquo;s what happened next:
Observation: Our Go services run on pods with 0.5 CPU cores but reported GOMAXPROCS=8 (matching the host machine&amp;rsquo;s 8-core configuration). Problem: This mismatch caused excessive CPU utilization due to thread contention. Solution: Using Uber&amp;rsquo;s automaxprocs to align GOMAXPROCS with the pod&amp;rsquo;s actual CPU limit resolved the issue.</description></item><item><title>Deploying Monitoring, Log Collection, and Alibaba Cloud ARMS with go-zero</title><link>https://sethix.com/posts/2023083117/</link><pubDate>Thu, 31 Aug 2023 17:50:44 +0800</pubDate><guid>https://sethix.com/posts/2023083117/</guid><description>Official steps from the documentation: https://go-zero.dev/docs/tutorials/monitor/index
Health Checks Name: user-api Host: 0.0.0.0 Port: 8002 DevServer: Enabled: true Port: 6470 HealthPath: &amp;#34;/healthz&amp;#34; Default health check port: 6470, default path: /healthz
You can use Alibaba Cloud&amp;rsquo;s Site Monitoring or similar services to periodically request this endpoint and ensure service availability.
Log Collection Logs can be written to stdout and aggregated using services like Alibaba Cloud SLS. Distributed Tracing Integration with Alibaba Cloud ARMS: https://arms.</description></item><item><title>Personal Single Server Microservices Practice</title><link>https://sethix.com/posts/2023082711/</link><pubDate>Sun, 27 Aug 2023 11:26:42 +0800</pubDate><guid>https://sethix.com/posts/2023082711/</guid><description>Preface Although I started working with microservices last year and deployed them on my personal server, they were all using direct connection mode. Today I took the opportunity to upgrade the go-zero codebase and revamp the architecture. Framework I continued using go-zero (https://github.com/zeromicro/go-zero) which was originally adopted last year, just updating to the latest version.
The code structure features a double-layer service under the root app directory, with shared code in pkg (e.</description></item><item><title>Building APIs Quickly with go-zero and gRPC Gateway</title><link>https://sethix.com/posts/2023081618/</link><pubDate>Wed, 16 Aug 2023 18:51:21 +0800</pubDate><guid>https://sethix.com/posts/2023081618/</guid><description>Official documentation provides a basic introduction. Here we&amp;rsquo;ll cover more advanced implementation details. Advanced Configuration Customizing request paths and methods hello.protobuf file syntax = &amp;#34;proto3&amp;#34;; package hello; option go_package = &amp;#34;./hello&amp;#34;; // Add import import &amp;#34;google/api/annotations.proto&amp;#34;; message Request { } message Response { string msg = 1; } service Hello { rpc Ping(Request) returns(Response) { // Add HTTP option option (google.api.http) = { post: &amp;#34;/api/v1/hello&amp;#34; body: &amp;#34;*&amp;#34; }; } } Update dependencies # Manually download annotations.</description></item><item><title>Service Registration and Discovery in Microservices</title><link>https://sethix.com/posts/2022061518/</link><pubDate>Wed, 15 Jun 2022 18:13:30 +0800</pubDate><guid>https://sethix.com/posts/2022061518/</guid><description>With service registration and discovery mechanisms, consumers don&amp;rsquo;t need to know the actual physical addresses of service providers to make calls, nor do they need to know how many providers are available. Service providers simply register with the registry to expose their services, without needing to know which specific services are consuming them.
RPC Configuration Name: user.rpc ListenOn: 0.0.0.0:8081 Etcd: Hosts: - 127.0.0.1:2379 Key: user.rpc Analyzing the etcd-related source code in go-zero.</description></item></channel></rss>