chore: 初始开源发布

iotlcm-sms:独立短信 HTTP/gRPC 服务,支持阿里云与腾讯云。

- Go module 迁移至 git.5iot.com/iotlcm-public/iotlcm-sms
- 补 Apache-2.0 LICENSE,重写 README(特性/配置/接口/部署/目录/测试)
- 配置改为 config.example.yaml + SMS_* 环境变量注入,仓库不含真实凭证
- 清理内部标识(私有镜像仓库 / 公司名 / 客户签名 / 真实模板ID / 真实手机号)
- 统一 LF 行尾并加 .gitattributes
This commit is contained in:
MiFaZhan
2026-10-22 14:21:47 +08:00
commit 4fb1016977
31 changed files with 2351 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/protobuf/encoding/protojson"
"git.5iot.com/iotlcm-public/iotlcm-sms/api/pb"
)
type requestFile struct {
Config json.RawMessage `json:"config"`
Params json.RawMessage `json:"params"`
}
func main() {
if len(os.Args) < 2 {
log.Fatalf("usage: go run ./examples/grpc_client <request.json> [host:port]")
}
address := "127.0.0.1:11200"
if len(os.Args) > 2 {
address = os.Args[2]
}
data, err := os.ReadFile(os.Args[1])
if err != nil {
log.Fatal(err)
}
var input requestFile
if err := json.Unmarshal(data, &input); err != nil {
log.Fatal(err)
}
conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatal(err)
}
defer conn.Close()
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
response, err := pb.NewNoticeClient(conn).Send(ctx, &pb.SendReq{
Head: &pb.HeadReq{
RouterId: time.Now().UnixNano(),
TraceId: fmt.Sprintf("grpc-example-%d", time.Now().Unix()),
},
Config: input.Config,
Params: input.Params,
})
if err != nil {
log.Fatal(err)
}
output, err := protojson.MarshalOptions{Indent: " "}.Marshal(response)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(output))
}