initial rewrite, use micro v4 and not cms-xxx stuff #4

Merged
vtolstov merged 24 commits from rewrite into master 2023-08-14 15:08:53 +03:00
13 changed files with 95 additions and 139 deletions
Showing only changes of commit a11bb6b95c - Show all commits

8
go.mod
View File

@ -17,16 +17,13 @@ require (
go.unistack.org/micro-server-http/v3 v3.11.6
go.unistack.org/micro-server-http/v4 v4.0.9
go.unistack.org/micro/v4 v4.0.6
go.unistack.org/protoc-gen-go-micro/v4 v4.0.5
go.unistack.org/protoc-gen-go-micro/v4 v4.0.6
golang.org/x/mod v0.12.0
golang.org/x/sync v0.3.0
google.golang.org/protobuf v1.31.0
)
require (
go.unistack.org/micro-client-http/v3 v3.9.3
go.unistack.org/micro/v3 v3.10.18
)
require go.unistack.org/micro-client-http/v4 v4.0.2
require (
dario.cat/mergo v1.0.0 // indirect
@ -77,6 +74,7 @@ require (
go.unistack.org/micro-config-flag/v3 v3.8.9 // indirect
go.unistack.org/micro-config-service/v3 v3.8.1 // indirect
go.unistack.org/micro-proto/v3 v3.3.1 // indirect
go.unistack.org/micro/v3 v3.10.18 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/net v0.12.0 // indirect

8
go.sum
View File

@ -1020,8 +1020,8 @@ go.unistack.org/cms-service v0.0.1 h1:XKKZqjQD3ViPGRzjadnVX94wQlKcWxompZac9YTeTj
go.unistack.org/cms-service v0.0.1/go.mod h1:3apbDEEgmoPfnPRpzgN40fCqbn/BdfXDk/Hvly8+bGk=
go.unistack.org/micro-broker-service/v3 v3.8.2 h1:K30wBLsoLO0WbD9rhPi8S8asU9pfes/M2X9tX9HLr24=
go.unistack.org/micro-broker-service/v3 v3.8.2/go.mod h1:qTlBl4vdJSl66SFIjdjOWFWKO0BFQ2ImbwiPCti/H8M=
go.unistack.org/micro-client-http/v3 v3.9.3 h1:5AicVsSwzAbIa1mpi99g5JhhDakUkgMV6e4F/Xyu3jI=
go.unistack.org/micro-client-http/v3 v3.9.3/go.mod h1:3zB0iVaYhG/xi0r/YvyTE422dOOOx1PAaiWlD2GSBlM=
go.unistack.org/micro-client-http/v4 v4.0.2 h1:0xsm2RCRWMfb1moeXQQ220uz52XE0R/PZvM9was/4lM=
go.unistack.org/micro-client-http/v4 v4.0.2/go.mod h1:Z9QT/upeqrp/rXVkL0lk6AzrkTdes0W3QlFlZ+ytkqM=
go.unistack.org/micro-codec-yaml/v3 v3.10.0 h1:cnNiWQZ3F+jsCX9DhEHBdIw8CjBItxb+TrKGGdlQ8F8=
go.unistack.org/micro-codec-yaml/v3 v3.10.0/go.mod h1:UzwC3QZZ6+PgKSudlGZNLkugXzOFkp3sxhs/CctEwBY=
go.unistack.org/micro-config-env/v3 v3.8.5 h1:k0BKpQflJ9mutzK//VcYw4XAKlKHTvg2GtkHTrEjbko=
@ -1047,8 +1047,8 @@ go.unistack.org/micro/v3 v3.10.18 h1:iz193N8eZKGrKPXuX6XMsGIRHMqdvUaZSfb9mzwlUYM
go.unistack.org/micro/v3 v3.10.18/go.mod h1:uMAc0U/x7dmtICCrblGf0ZLgYegu3VwQAquu+OFCw1Q=
go.unistack.org/micro/v4 v4.0.6 h1:YFWvTh3VwyOd6NHYTQcf47n2TF5+p/EhpnbuBQX3qhk=
go.unistack.org/micro/v4 v4.0.6/go.mod h1:bVEYTlPi0EsdgZZt311bIroDg9ict7ky3C87dSCCAGk=
go.unistack.org/protoc-gen-go-micro/v4 v4.0.5 h1:1QTAN51nkQ3uAX0yxH1Ypti1ErghGN1goPA0D6Vnq9c=
go.unistack.org/protoc-gen-go-micro/v4 v4.0.5/go.mod h1:9bsKAlESlPXPBSmY/NDLL//smZbhnEMrnWyG+M8zVFA=
go.unistack.org/protoc-gen-go-micro/v4 v4.0.6 h1:qe6huziuXqRnsgvDSiaT1DR20iL676w37PMkdBEjvEk=
go.unistack.org/protoc-gen-go-micro/v4 v4.0.6/go.mod h1:9bsKAlESlPXPBSmY/NDLL//smZbhnEMrnWyG+M8zVFA=
golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=

View File

@ -65,7 +65,8 @@ paths:
in: path
required: true
schema:
$ref: '#/components/schemas/UInt64Value'
type: integer
format: uint64
requestBody:
content:
application/json:
@ -139,7 +140,8 @@ components:
type: object
properties:
idPackage:
$ref: '#/components/schemas/UInt64Value'
type: integer
format: uint64
text:
type: string
AddCommentRsp:
@ -152,9 +154,9 @@ components:
type: object
properties:
name:
$ref: '#/components/schemas/StringValue'
type: string
url:
$ref: '#/components/schemas/StringValue'
type: string
modules:
type: array
items:
@ -162,7 +164,9 @@ components:
format: uint64
AddPackageRsp:
type: object
properties: {}
properties:
status:
type: string
Error:
type: object
properties:
@ -233,30 +237,16 @@ components:
items:
type: integer
format: uint64
StringValue:
type: object
properties:
value:
type: string
description: The string value.
description: Wrapper message for `string`. The JSON representation for `StringValue` is JSON string.
UInt64Value:
type: object
properties:
value:
type: integer
description: The uint64 value.
format: uint64
description: Wrapper message for `uint64`. The JSON representation for `UInt64Value` is JSON string.
UpdatePackageReq:
type: object
properties:
id:
$ref: '#/components/schemas/UInt64Value'
type: integer
format: uint64
name:
$ref: '#/components/schemas/StringValue'
type: string
url:
$ref: '#/components/schemas/StringValue'
type: string
modules:
type: array
items:

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// versions:
// - protoc-gen-go-micro v3.10.3
// - protoc-gen-go-micro v4.0.2
// - protoc v4.23.4
// source: pkgdash.proto
@ -8,53 +8,13 @@ package pkgdashpb
import (
context "context"
v3 "go.unistack.org/micro-server-http/v3"
client "go.unistack.org/micro/v3/client"
client "go.unistack.org/micro/v4/client"
emptypb "google.golang.org/protobuf/types/known/emptypb"
)
var (
PkgdashServiceName = "PkgdashService"
)
var (
PkgdashServiceServerEndpoints = []v3.EndpointMetadata{
{
Name: "PkgdashService.ListPackage",
Path: "/v1/packages",
Method: "GET",
Body: "",
Stream: false,
},
{
Name: "PkgdashService.UpdatePackage",
Path: "/v1/package/{id}",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.AddComment",
Path: "/v1/package/{pkg}/comment",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.AddPackage",
Path: "/v1/package",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.GetModule",
Path: "/v1/module",
Method: "GET",
Body: "",
Stream: false,
},
}
)
type PkgdashServiceClient interface {
ListPackage(ctx context.Context, req *emptypb.Empty, opts ...client.CallOption) (*ListPackageRsp, error)

View File

@ -1,19 +1,59 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.10.3
// protoc-gen-go-micro version: v4.0.2
// source: pkgdash.proto
package pkgdashpb
import (
context "context"
v3 "go.unistack.org/micro-client-http/v3"
v31 "go.unistack.org/micro-server-http/v3"
client "go.unistack.org/micro/v3/client"
server "go.unistack.org/micro/v3/server"
v41 "go.unistack.org/micro-client-http/v4"
v4 "go.unistack.org/micro-server-http/v4"
client "go.unistack.org/micro/v4/client"
server "go.unistack.org/micro/v4/server"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
)
var (
PkgdashServiceServerEndpoints = []v4.EndpointMetadata{
{
Name: "PkgdashService.ListPackage",
Path: "/v1/packages",
Method: "GET",
Body: "",
Stream: false,
},
{
Name: "PkgdashService.UpdatePackage",
Path: "/v1/package/{id}",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.AddComment",
Path: "/v1/package/{pkg}/comment",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.AddPackage",
Path: "/v1/package",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.GetModule",
Path: "/v1/module",
Method: "GET",
Body: "",
Stream: false,
},
}
)
type pkgdashServiceClient struct {
c client.Client
name string
@ -27,11 +67,11 @@ func (c *pkgdashServiceClient) ListPackage(ctx context.Context, req *emptypb.Emp
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodGet),
v3.Path("/v1/packages"),
v41.Method(http.MethodGet),
v41.Path("/v1/packages"),
)
rsp := &ListPackageRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.ListPackage", req), rsp, opts...)
@ -45,12 +85,12 @@ func (c *pkgdashServiceClient) UpdatePackage(ctx context.Context, req *UpdatePac
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/package/{id}"),
v3.Body("*"),
v41.Method(http.MethodPost),
v41.Path("/v1/package/{id}"),
v41.Body("*"),
)
rsp := &UpdatePackageRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.UpdatePackage", req), rsp, opts...)
@ -64,12 +104,12 @@ func (c *pkgdashServiceClient) AddComment(ctx context.Context, req *AddCommentRe
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/package/{pkg}/comment"),
v3.Body("*"),
v41.Method(http.MethodPost),
v41.Path("/v1/package/{pkg}/comment"),
v41.Body("*"),
)
rsp := &AddCommentRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.AddComment", req), rsp, opts...)
@ -83,12 +123,12 @@ func (c *pkgdashServiceClient) AddPackage(ctx context.Context, req *AddPackageRe
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/package"),
v3.Body("*"),
v41.Method(http.MethodPost),
v41.Path("/v1/package"),
v41.Body("*"),
)
rsp := &AddPackageRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.AddPackage", req), rsp, opts...)
@ -102,11 +142,11 @@ func (c *pkgdashServiceClient) GetModule(ctx context.Context, req *GetModuleReq,
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodGet),
v3.Path("/v1/module"),
v41.Method(http.MethodGet),
v41.Path("/v1/module"),
)
rsp := &GetModuleRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.GetModule", req), rsp, opts...)
@ -153,6 +193,6 @@ func RegisterPkgdashServiceServer(s server.Server, sh PkgdashServiceServer, opts
}
h := &pkgdashServiceServer{sh}
var nopts []server.HandlerOption
nopts = append(nopts, v31.HandlerEndpoints(PkgdashServiceServerEndpoints))
nopts = append(nopts, v4.HandlerEndpoints(PkgdashServiceServerEndpoints))
return s.Handle(s.NewHandler(&PkgdashService{h}, append(nopts, opts...)...))
}

View File

@ -10,7 +10,5 @@ export { GetModuleRsp } from './models/get-module-rsp';
export { ListPackageRsp } from './models/list-package-rsp';
export { Module } from './models/module';
export { Package } from './models/package';
export { StringValue } from './models/string-value';
export { UInt64Value } from './models/u-int-64-value';
export { UpdatePackageReq } from './models/update-package-req';
export { UpdatePackageRsp } from './models/update-package-rsp';

View File

@ -1,7 +1,6 @@
/* tslint:disable */
/* eslint-disable */
import { UInt64Value } from './u-int-64-value';
export interface AddCommentReq {
idPackage?: UInt64Value;
idPackage?: number;
text?: string;
}

View File

@ -1,8 +1,7 @@
/* tslint:disable */
/* eslint-disable */
import { StringValue } from './string-value';
export interface AddPackageReq {
modules?: Array<number>;
name?: StringValue;
url?: StringValue;
name?: string;
url?: string;
}

View File

@ -1,4 +1,5 @@
/* tslint:disable */
/* eslint-disable */
export interface AddPackageRsp {
status?: string;
}

View File

@ -1,13 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* Wrapper message for `string`. The JSON representation for `StringValue` is JSON string.
*/
export interface StringValue {
/**
* The string value.
*/
value?: string;
}

View File

@ -1,13 +0,0 @@
/* tslint:disable */
/* eslint-disable */
/**
* Wrapper message for `uint64`. The JSON representation for `UInt64Value` is JSON string.
*/
export interface UInt64Value {
/**
* The uint64 value.
*/
value?: number;
}

View File

@ -1,11 +1,9 @@
/* tslint:disable */
/* eslint-disable */
import { StringValue } from './string-value';
import { UInt64Value } from './u-int-64-value';
export interface UpdatePackageReq {
id?: UInt64Value;
id?: number;
issues?: Array<number>;
modules?: Array<number>;
name?: StringValue;
url?: StringValue;
name?: string;
url?: string;
}

View File

@ -16,7 +16,6 @@ import { AddPackageReq } from '../models/add-package-req';
import { AddPackageRsp } from '../models/add-package-rsp';
import { GetModuleRsp } from '../models/get-module-rsp';
import { ListPackageRsp } from '../models/list-package-rsp';
import { UInt64Value } from '../models/u-int-64-value';
import { UpdatePackageReq } from '../models/update-package-req';
import { UpdatePackageRsp } from '../models/update-package-rsp';
@ -131,7 +130,7 @@ export class PkgdashServiceService extends BaseService {
*/
updateInfo$Response(
params: {
id: UInt64Value;
id: number;
body: UpdatePackageReq
},
context?: HttpContext
@ -160,7 +159,7 @@ export class PkgdashServiceService extends BaseService {
*/
updateInfo(
params: {
id: UInt64Value;
id: number;
body: UpdatePackageReq
},
context?: HttpContext