refactor: reorganize modules and add Linux build tooling

This commit is contained in:
2026-08-09 12:41:08 +08:00
parent 86024fa81d
commit 5cc5fd92ed
1461 changed files with 4054 additions and 4724 deletions

View File

@@ -0,0 +1,267 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: ads.proto
package ads
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ByPosRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ByPosRequest) Reset() {
*x = ByPosRequest{}
mi := &file_ads_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ByPosRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ByPosRequest) ProtoMessage() {}
func (x *ByPosRequest) ProtoReflect() protoreflect.Message {
mi := &file_ads_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ByPosRequest.ProtoReflect.Descriptor instead.
func (*ByPosRequest) Descriptor() ([]byte, []int) {
return file_ads_proto_rawDescGZIP(), []int{0}
}
func (x *ByPosRequest) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
type ByPosReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data []*AdsItem `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ByPosReply) Reset() {
*x = ByPosReply{}
mi := &file_ads_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ByPosReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ByPosReply) ProtoMessage() {}
func (x *ByPosReply) ProtoReflect() protoreflect.Message {
mi := &file_ads_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ByPosReply.ProtoReflect.Descriptor instead.
func (*ByPosReply) Descriptor() ([]byte, []int) {
return file_ads_proto_rawDescGZIP(), []int{1}
}
func (x *ByPosReply) GetData() []*AdsItem {
if x != nil {
return x.Data
}
return nil
}
type AdsItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` //广告名称
Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` //广告内容
Type int32 `protobuf:"varint,4,opt,name=type,proto3" json:"type,omitempty"` //广告类型 1.文本 2.图片 3.视频
ToUrl string `protobuf:"bytes,5,opt,name=toUrl,proto3" json:"toUrl,omitempty"`
Created string `protobuf:"bytes,6,opt,name=created,proto3" json:"created,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AdsItem) Reset() {
*x = AdsItem{}
mi := &file_ads_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AdsItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AdsItem) ProtoMessage() {}
func (x *AdsItem) ProtoReflect() protoreflect.Message {
mi := &file_ads_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AdsItem.ProtoReflect.Descriptor instead.
func (*AdsItem) Descriptor() ([]byte, []int) {
return file_ads_proto_rawDescGZIP(), []int{2}
}
func (x *AdsItem) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *AdsItem) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *AdsItem) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
func (x *AdsItem) GetType() int32 {
if x != nil {
return x.Type
}
return 0
}
func (x *AdsItem) GetToUrl() string {
if x != nil {
return x.ToUrl
}
return ""
}
func (x *AdsItem) GetCreated() string {
if x != nil {
return x.Created
}
return ""
}
var File_ads_proto protoreflect.FileDescriptor
const file_ads_proto_rawDesc = "" +
"\n" +
"\x12base/ads/ads.proto\x12\x03ads\" \n" +
"\fByPosRequest\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\".\n" +
"\n" +
"ByPosReply\x12 \n" +
"\x04data\x18\x01 \x03(\v2\f.ads.AdsItemR\x04data\"\x8d\x01\n" +
"\aAdsItem\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" +
"\x05title\x18\x02 \x01(\tR\x05title\x12\x18\n" +
"\acontent\x18\x03 \x01(\tR\acontent\x12\x12\n" +
"\x04type\x18\x04 \x01(\x05R\x04type\x12\x14\n" +
"\x05toUrl\x18\x05 \x01(\tR\x05toUrl\x12\x18\n" +
"\acreated\x18\x06 \x01(\tR\acreated26\n" +
"\x05Fetch\x12-\n" +
"\x05ByPos\x12\x11.ads.ByPosRequest\x1a\x0f.ads.ByPosReply\"\x00B\aZ\x05.;adsb\x06proto3"
var (
file_ads_proto_rawDescOnce sync.Once
file_ads_proto_rawDescData []byte
)
func file_ads_proto_rawDescGZIP() []byte {
file_ads_proto_rawDescOnce.Do(func() {
file_ads_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_ads_proto_rawDesc), len(file_ads_proto_rawDesc)))
})
return file_ads_proto_rawDescData
}
var file_ads_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_ads_proto_goTypes = []any{
(*ByPosRequest)(nil), // 0: ads.ByPosRequest
(*ByPosReply)(nil), // 1: ads.ByPosReply
(*AdsItem)(nil), // 2: ads.AdsItem
}
var file_ads_proto_depIdxs = []int32{
2, // 0: ads.ByPosReply.data:type_name -> ads.AdsItem
0, // 1: ads.Fetch.ByPos:input_type -> ads.ByPosRequest
1, // 2: ads.Fetch.ByPos:output_type -> ads.ByPosReply
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_ads_proto_init() }
func file_ads_proto_init() {
if File_ads_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_ads_proto_rawDesc), len(file_ads_proto_rawDesc)),
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_ads_proto_goTypes,
DependencyIndexes: file_ads_proto_depIdxs,
MessageInfos: file_ads_proto_msgTypes,
}.Build()
File_ads_proto = out.File
file_ads_proto_goTypes = nil
file_ads_proto_depIdxs = nil
}

View File

@@ -0,0 +1,157 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: ads.proto
/*
Package ads is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package ads
import (
"context"
"errors"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var (
_ codes.Code
_ io.Reader
_ status.Status
_ = errors.New
_ = runtime.String
_ = utilities.NewDoubleArray
_ = metadata.Join
)
func request_Fetch_ByPos_0(ctx context.Context, marshaler runtime.Marshaler, client FetchClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq ByPosRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
msg, err := client.ByPos(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Fetch_ByPos_0(ctx context.Context, marshaler runtime.Marshaler, server FetchServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq ByPosRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ByPos(ctx, &protoReq)
return msg, metadata, err
}
// RegisterFetchHandlerServer registers the http handlers for service Fetch to "mux".
// UnaryRPC :call FetchServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterFetchHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterFetchHandlerServer(ctx context.Context, mux *runtime.ServeMux, server FetchServer) error {
mux.Handle(http.MethodPost, pattern_Fetch_ByPos_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/ads.Fetch/ByPos", runtime.WithHTTPPathPattern("/ads.Fetch/ByPos"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Fetch_ByPos_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Fetch_ByPos_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterFetchHandlerFromEndpoint is same as RegisterFetchHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterFetchHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterFetchHandler(ctx, mux, conn)
}
// RegisterFetchHandler registers the http handlers for service Fetch to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterFetchHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterFetchHandlerClient(ctx, mux, NewFetchClient(conn))
}
// RegisterFetchHandlerClient registers the http handlers for service Fetch
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "FetchClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "FetchClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "FetchClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterFetchHandlerClient(ctx context.Context, mux *runtime.ServeMux, client FetchClient) error {
mux.Handle(http.MethodPost, pattern_Fetch_ByPos_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/ads.Fetch/ByPos", runtime.WithHTTPPathPattern("/ads.Fetch/ByPos"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Fetch_ByPos_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Fetch_ByPos_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Fetch_ByPos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"ads.Fetch", "ByPos"}, ""))
)
var (
forward_Fetch_ByPos_0 = runtime.ForwardResponseMessage
)

View File

@@ -0,0 +1,127 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc (unknown)
// source: ads.proto
package ads
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
Fetch_ByPos_FullMethodName = "/ads.Fetch/ByPos"
)
// FetchClient is the client API for Fetch service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// 广告子系统
type FetchClient interface {
//通过广告位获取广告信息
ByPos(ctx context.Context, in *ByPosRequest, opts ...grpc.CallOption) (*ByPosReply, error)
}
type fetchClient struct {
cc grpc.ClientConnInterface
}
func NewFetchClient(cc grpc.ClientConnInterface) FetchClient {
return &fetchClient{cc}
}
func (c *fetchClient) ByPos(ctx context.Context, in *ByPosRequest, opts ...grpc.CallOption) (*ByPosReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ByPosReply)
err := c.cc.Invoke(ctx, Fetch_ByPos_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// FetchServer is the server API for Fetch service.
// All implementations must embed UnimplementedFetchServer
// for forward compatibility.
//
// 广告子系统
type FetchServer interface {
//通过广告位获取广告信息
ByPos(context.Context, *ByPosRequest) (*ByPosReply, error)
mustEmbedUnimplementedFetchServer()
}
// UnimplementedFetchServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedFetchServer struct{}
func (UnimplementedFetchServer) ByPos(context.Context, *ByPosRequest) (*ByPosReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ByPos not implemented")
}
func (UnimplementedFetchServer) mustEmbedUnimplementedFetchServer() {}
func (UnimplementedFetchServer) testEmbeddedByValue() {}
// UnsafeFetchServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to FetchServer will
// result in compilation errors.
type UnsafeFetchServer interface {
mustEmbedUnimplementedFetchServer()
}
func RegisterFetchServer(s grpc.ServiceRegistrar, srv FetchServer) {
// If the following call pancis, it indicates UnimplementedFetchServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&Fetch_ServiceDesc, srv)
}
func _Fetch_ByPos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ByPosRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(FetchServer).ByPos(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Fetch_ByPos_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(FetchServer).ByPos(ctx, req.(*ByPosRequest))
}
return interceptor(ctx, in, info, handler)
}
// Fetch_ServiceDesc is the grpc.ServiceDesc for Fetch service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Fetch_ServiceDesc = grpc.ServiceDesc{
ServiceName: "ads.Fetch",
HandlerType: (*FetchServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ByPos",
Handler: _Fetch_ByPos_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "ads.proto",
}