Merge branch 'rewrite'
# Conflicts: # cmd/script/main.go # go.mod # go.sum # handler/handlers.go # handler/writer.go # proto/go_generate/dashboard.pb.go # proto/micro/dashboard_micro.pb.go # proto/micro/dashboard_micro_http.pb.go # proto/pkgdash.pb.validate.go # service/client_git/client.go # service/client_git/client_test.go # service/service.go # storage/postgres/quries.go # storage/postgres/storage.go # storage/sqlite/storage.go # storage/storage.go # storage/storage_test.go
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
//go:build tools
|
||||
// +build tools
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
_ "github.com/envoyproxy/protoc-gen-validate"
|
||||
_ "go.unistack.org/micro-proto/v3"
|
||||
)
|
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.3
|
||||
// - protoc v4.23.4
|
||||
// source: dashboard.proto
|
||||
|
||||
package go_generate
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
go_generate "go.unistack.org/unistack-org/pkgdash/proto/go_generate"
|
||||
)
|
||||
|
||||
var (
|
||||
DashboardServiceName = "DashboardService"
|
||||
)
|
||||
var (
|
||||
DashboardServiceServerEndpoints = []v3.EndpointMetadata{}
|
||||
)
|
||||
|
||||
type DashboardServiceClient interface {
|
||||
ListPackage(ctx context.Context, req *go_generate.ListPackageReq, opts ...client.CallOption) (*go_generate.ListPackageRsp, error)
|
||||
UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, opts ...client.CallOption) (*go_generate.UpdatePackageRsp, error)
|
||||
AddComment(ctx context.Context, req *go_generate.AddCommentReq, opts ...client.CallOption) (*go_generate.AddCommentRsp, error)
|
||||
AddPackage(ctx context.Context, req *go_generate.AddPackageReq, opts ...client.CallOption) (*go_generate.AddPackageRsp, error)
|
||||
GetModule(ctx context.Context, req *go_generate.GetModuleReq, opts ...client.CallOption) (*go_generate.GetModuleRsp, error)
|
||||
}
|
||||
|
||||
type DashboardServiceServer interface {
|
||||
ListPackage(ctx context.Context, req *go_generate.ListPackageReq, rsp *go_generate.ListPackageRsp) error
|
||||
UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, rsp *go_generate.UpdatePackageRsp) error
|
||||
AddComment(ctx context.Context, req *go_generate.AddCommentReq, rsp *go_generate.AddCommentRsp) error
|
||||
AddPackage(ctx context.Context, req *go_generate.AddPackageReq, rsp *go_generate.AddPackageRsp) error
|
||||
GetModule(ctx context.Context, req *go_generate.GetModuleReq, rsp *go_generate.GetModuleRsp) error
|
||||
}
|
||||
|
@@ -1,109 +0,0 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// protoc-gen-go-micro version: v3.10.3
|
||||
// source: dashboard.proto
|
||||
|
||||
package go_generate
|
||||
|
||||
import (
|
||||
context "context"
|
||||
_ "go.unistack.org/micro-client-http/v3"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
go_generate "go.unistack.org/unistack-org/pkgdash/proto/go_generate"
|
||||
)
|
||||
|
||||
type dashboardServiceClient struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewDashboardServiceClient(name string, c client.Client) DashboardServiceClient {
|
||||
return &dashboardServiceClient{c: c, name: name}
|
||||
}
|
||||
|
||||
func (c *dashboardServiceClient) ListPackage(ctx context.Context, req *go_generate.ListPackageReq, opts ...client.CallOption) (*go_generate.ListPackageRsp, error) {
|
||||
rsp := &go_generate.ListPackageRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "DashboardService.ListPackage", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *dashboardServiceClient) UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, opts ...client.CallOption) (*go_generate.UpdatePackageRsp, error) {
|
||||
rsp := &go_generate.UpdatePackageRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "DashboardService.UpdatePackage", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *dashboardServiceClient) AddComment(ctx context.Context, req *go_generate.AddCommentReq, opts ...client.CallOption) (*go_generate.AddCommentRsp, error) {
|
||||
rsp := &go_generate.AddCommentRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "DashboardService.AddComment", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *dashboardServiceClient) AddPackage(ctx context.Context, req *go_generate.AddPackageReq, opts ...client.CallOption) (*go_generate.AddPackageRsp, error) {
|
||||
rsp := &go_generate.AddPackageRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "DashboardService.AddPackage", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *dashboardServiceClient) GetModule(ctx context.Context, req *go_generate.GetModuleReq, opts ...client.CallOption) (*go_generate.GetModuleRsp, error) {
|
||||
rsp := &go_generate.GetModuleRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "DashboardService.GetModule", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
type dashboardServiceServer struct {
|
||||
DashboardServiceServer
|
||||
}
|
||||
|
||||
func (h *dashboardServiceServer) ListPackage(ctx context.Context, req *go_generate.ListPackageReq, rsp *go_generate.ListPackageRsp) error {
|
||||
return h.DashboardServiceServer.ListPackage(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *dashboardServiceServer) UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, rsp *go_generate.UpdatePackageRsp) error {
|
||||
return h.DashboardServiceServer.UpdatePackage(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *dashboardServiceServer) AddComment(ctx context.Context, req *go_generate.AddCommentReq, rsp *go_generate.AddCommentRsp) error {
|
||||
return h.DashboardServiceServer.AddComment(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *dashboardServiceServer) AddPackage(ctx context.Context, req *go_generate.AddPackageReq, rsp *go_generate.AddPackageRsp) error {
|
||||
return h.DashboardServiceServer.AddPackage(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *dashboardServiceServer) GetModule(ctx context.Context, req *go_generate.GetModuleReq, rsp *go_generate.GetModuleRsp) error {
|
||||
return h.DashboardServiceServer.GetModule(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func RegisterDashboardServiceServer(s server.Server, sh DashboardServiceServer, opts ...server.HandlerOption) error {
|
||||
type dashboardService interface {
|
||||
ListPackage(ctx context.Context, req *go_generate.ListPackageReq, rsp *go_generate.ListPackageRsp) error
|
||||
UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, rsp *go_generate.UpdatePackageRsp) error
|
||||
AddComment(ctx context.Context, req *go_generate.AddCommentReq, rsp *go_generate.AddCommentRsp) error
|
||||
AddPackage(ctx context.Context, req *go_generate.AddPackageReq, rsp *go_generate.AddPackageRsp) error
|
||||
GetModule(ctx context.Context, req *go_generate.GetModuleReq, rsp *go_generate.GetModuleRsp) error
|
||||
}
|
||||
type DashboardService struct {
|
||||
dashboardService
|
||||
}
|
||||
h := &dashboardServiceServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(DashboardServiceServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&DashboardService{h}, append(nopts, opts...)...))
|
||||
}
|
||||
|
1487
proto/pkgdash.pb.go
Normal file
1487
proto/pkgdash.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-validate. DO NOT EDIT.
|
||||
// source: dashboard.proto
|
||||
// source: pkgdash.proto
|
||||
|
||||
package go_generate
|
||||
package pkgdashpb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -89,7 +89,6 @@ func (m *ErrorRsp) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return ErrorRspMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -195,7 +194,6 @@ func (m *Error) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return ErrorMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -326,7 +324,6 @@ func (m *Package) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return PackageMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -479,7 +476,6 @@ func (m *Module) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return ModuleMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -621,7 +617,6 @@ func (m *Issue) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return IssueMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -765,7 +760,6 @@ func (m *Comment) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return CommentMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -864,7 +858,6 @@ func (m *ListPackageReq) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return ListPackageReqMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -998,7 +991,6 @@ func (m *ListPackageRsp) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return ListPackageRspMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1218,7 +1210,6 @@ func (m *UpdatePackageReq) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return UpdatePackageReqMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1329,7 +1320,6 @@ func (m *UpdatePackageRsp) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return UpdatePackageRspMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1404,6 +1394,117 @@ var _ interface {
|
||||
ErrorName() string
|
||||
} = UpdatePackageRspValidationError{}
|
||||
|
||||
// Validate checks the field values on CommentReq with the rules defined in the
|
||||
// proto definition for this message. If any rules are violated, the first
|
||||
// error encountered is returned, or nil if there are no violations.
|
||||
func (m *CommentReq) Validate() error {
|
||||
return m.validate(false)
|
||||
}
|
||||
|
||||
// ValidateAll checks the field values on CommentReq with the rules defined in
|
||||
// the proto definition for this message. If any rules are violated, the
|
||||
// result is a list of violation errors wrapped in CommentReqMultiError, or
|
||||
// nil if none found.
|
||||
func (m *CommentReq) ValidateAll() error {
|
||||
return m.validate(true)
|
||||
}
|
||||
|
||||
func (m *CommentReq) validate(all bool) error {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var errors []error
|
||||
|
||||
if m.GetPkg() <= 0 {
|
||||
err := CommentReqValidationError{
|
||||
field: "Pkg",
|
||||
reason: "value must be greater than 0",
|
||||
}
|
||||
if !all {
|
||||
return err
|
||||
}
|
||||
errors = append(errors, err)
|
||||
}
|
||||
|
||||
// no validation rules for Text
|
||||
|
||||
if len(errors) > 0 {
|
||||
return CommentReqMultiError(errors)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CommentReqMultiError is an error wrapping multiple validation errors
|
||||
// returned by CommentReq.ValidateAll() if the designated constraints aren't met.
|
||||
type CommentReqMultiError []error
|
||||
|
||||
// Error returns a concatenation of all the error messages it wraps.
|
||||
func (m CommentReqMultiError) Error() string {
|
||||
var msgs []string
|
||||
for _, err := range m {
|
||||
msgs = append(msgs, err.Error())
|
||||
}
|
||||
return strings.Join(msgs, "; ")
|
||||
}
|
||||
|
||||
// AllErrors returns a list of validation violation errors.
|
||||
func (m CommentReqMultiError) AllErrors() []error { return m }
|
||||
|
||||
// CommentReqValidationError is the validation error returned by
|
||||
// CommentReq.Validate if the designated constraints aren't met.
|
||||
type CommentReqValidationError struct {
|
||||
field string
|
||||
reason string
|
||||
cause error
|
||||
key bool
|
||||
}
|
||||
|
||||
// Field function returns field value.
|
||||
func (e CommentReqValidationError) Field() string { return e.field }
|
||||
|
||||
// Reason function returns reason value.
|
||||
func (e CommentReqValidationError) Reason() string { return e.reason }
|
||||
|
||||
// Cause function returns cause value.
|
||||
func (e CommentReqValidationError) Cause() error { return e.cause }
|
||||
|
||||
// Key function returns key value.
|
||||
func (e CommentReqValidationError) Key() bool { return e.key }
|
||||
|
||||
// ErrorName returns error name.
|
||||
func (e CommentReqValidationError) ErrorName() string { return "CommentReqValidationError" }
|
||||
|
||||
// Error satisfies the builtin error interface
|
||||
func (e CommentReqValidationError) Error() string {
|
||||
cause := ""
|
||||
if e.cause != nil {
|
||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||
}
|
||||
|
||||
key := ""
|
||||
if e.key {
|
||||
key = "key for "
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"invalid %sCommentReq.%s: %s%s",
|
||||
key,
|
||||
e.field,
|
||||
e.reason,
|
||||
cause)
|
||||
}
|
||||
|
||||
var _ error = CommentReqValidationError{}
|
||||
|
||||
var _ interface {
|
||||
Field() string
|
||||
Reason() string
|
||||
Key() bool
|
||||
Cause() error
|
||||
ErrorName() string
|
||||
} = CommentReqValidationError{}
|
||||
|
||||
// Validate checks the field values on AddCommentReq with the rules defined in
|
||||
// the proto definition for this message. If any rules are violated, the first
|
||||
// error encountered is returned, or nil if there are no violations.
|
||||
@@ -1471,7 +1572,6 @@ func (m *AddCommentReq) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return AddCommentReqMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1582,7 +1682,6 @@ func (m *AddCommentRsp) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return AddCommentRspMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1762,7 +1861,6 @@ func (m *AddPackageReq) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return AddPackageReqMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1862,7 +1960,6 @@ func (m *AddPackageRsp) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return AddPackageRspMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1962,7 +2059,6 @@ func (m *GetModuleReq) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return GetModuleReqMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2095,7 +2191,6 @@ func (m *GetModuleRsp) validate(all bool) error {
|
||||
if len(errors) > 0 {
|
||||
return GetModuleRspMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@@ -1,18 +1,83 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package proto;
|
||||
package pkgdash;
|
||||
|
||||
option go_package = "go.unistack.org/unistack-org/pkgdash/proto/go_generate;go_generate";
|
||||
option go_package = "go.unistack.org/unistack-org/pkgdash/proto;pkgdashpb";
|
||||
|
||||
import "api/annotations.proto";
|
||||
import "openapiv3/annotations.proto";
|
||||
import "validate/validate.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
service DashboardService {
|
||||
rpc ListPackage(ListPackageReq) returns (ListPackageRsp) {};
|
||||
rpc UpdatePackage(UpdatePackageReq) returns (UpdatePackageRsp) {};
|
||||
rpc AddComment(AddCommentReq) returns (AddCommentRsp) {};
|
||||
rpc AddPackage(AddPackageReq) returns (AddPackageRsp) {};
|
||||
rpc GetModule(GetModuleReq) returns (GetModuleRsp) {};
|
||||
service PkgdashService {
|
||||
rpc ListPackage(ListPackageReq) returns (ListPackageRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "ListPackage";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
get: "/v1/packages";
|
||||
};
|
||||
};
|
||||
rpc UpdatePackage(UpdatePackageReq) returns (UpdatePackageRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "UpdateInfo";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
post: "/v1/package/{id}";
|
||||
body: "*";
|
||||
};
|
||||
};
|
||||
rpc AddComment(AddCommentReq) returns (AddCommentRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "AddComment";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
post: "/v1/package/{pkg}/comment";
|
||||
body: "*";
|
||||
};
|
||||
};
|
||||
rpc AddPackage(AddPackageReq) returns (AddPackageRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "AddPackage";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
post: "/v1/package";
|
||||
body: "*";
|
||||
};
|
||||
};
|
||||
rpc GetModule(GetModuleReq) returns (GetModuleRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "GetModule";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {_ref: ".pkgdash.ErrorRsp"};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = {
|
||||
get: "/v1/module";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
message ErrorRsp {
|
||||
@@ -75,6 +140,11 @@ message UpdatePackageRsp {
|
||||
uint64 id = 1 [(validate.rules).uint64.gt = 0];
|
||||
}
|
||||
|
||||
message CommentReq {
|
||||
uint64 pkg = 1 [(validate.rules).uint64.gt = 0];
|
||||
string text = 2;
|
||||
}
|
||||
|
||||
message AddCommentReq {
|
||||
google.protobuf.UInt64Value idPackage = 1 [(validate.rules).message.required = true];
|
||||
string text = 2;
|
||||
@@ -89,6 +159,7 @@ message AddPackageReq {
|
||||
google.protobuf.StringValue url = 2 [(validate.rules).message.required = true];
|
||||
repeated uint64 modules = 3;
|
||||
}
|
||||
|
||||
message AddPackageRsp{}
|
||||
|
||||
message GetModuleReq {
|
33
proto/pkgdash_micro.pb.go
Normal file
33
proto/pkgdash_micro.pb.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v4.0.2
|
||||
// - protoc v4.23.4
|
||||
// source: pkgdash.proto
|
||||
|
||||
package pkgdashpb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
_ "go.unistack.org/micro/v4/client"
|
||||
options "go.unistack.org/micro/v4/options"
|
||||
)
|
||||
|
||||
var (
|
||||
PkgdashServiceName = "PkgdashService"
|
||||
)
|
||||
|
||||
type PkgdashServiceClient interface {
|
||||
ListPackage(ctx context.Context, req *ListPackageReq, opts ...options.Option) (*ListPackageRsp, error)
|
||||
UpdatePackage(ctx context.Context, req *UpdatePackageReq, opts ...options.Option) (*UpdatePackageRsp, error)
|
||||
AddComment(ctx context.Context, req *AddCommentReq, opts ...options.Option) (*AddCommentRsp, error)
|
||||
AddPackage(ctx context.Context, req *AddPackageReq, opts ...options.Option) (*AddPackageRsp, error)
|
||||
GetModule(ctx context.Context, req *GetModuleReq, opts ...options.Option) (*GetModuleRsp, error)
|
||||
}
|
||||
|
||||
type PkgdashServiceServer interface {
|
||||
ListPackage(ctx context.Context, req *ListPackageReq, rsp *ListPackageRsp) error
|
||||
UpdatePackage(ctx context.Context, req *UpdatePackageReq, rsp *UpdatePackageRsp) error
|
||||
AddComment(ctx context.Context, req *AddCommentReq, rsp *AddCommentRsp) error
|
||||
AddPackage(ctx context.Context, req *AddPackageReq, rsp *AddPackageRsp) error
|
||||
GetModule(ctx context.Context, req *GetModuleReq, rsp *GetModuleRsp) error
|
||||
}
|
198
proto/pkgdash_micro_http.pb.go
Normal file
198
proto/pkgdash_micro_http.pb.go
Normal file
@@ -0,0 +1,198 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// protoc-gen-go-micro version: v4.0.2
|
||||
// source: pkgdash.proto
|
||||
|
||||
package pkgdashpb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v41 "go.unistack.org/micro-client-http/v4"
|
||||
v4 "go.unistack.org/micro-server-http/v4"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
options "go.unistack.org/micro/v4/options"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
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
|
||||
}
|
||||
|
||||
func NewPkgdashServiceClient(name string, c client.Client) PkgdashServiceClient {
|
||||
return &pkgdashServiceClient{c: c, name: name}
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) ListPackage(ctx context.Context, req *ListPackageReq, opts ...options.Option) (*ListPackageRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
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...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) UpdatePackage(ctx context.Context, req *UpdatePackageReq, opts ...options.Option) (*UpdatePackageRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
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...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) AddComment(ctx context.Context, req *AddCommentReq, opts ...options.Option) (*AddCommentRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
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...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) AddPackage(ctx context.Context, req *AddPackageReq, opts ...options.Option) (*AddPackageRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
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...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
func (c *pkgdashServiceClient) GetModule(ctx context.Context, req *GetModuleReq, opts ...options.Option) (*GetModuleRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v41.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
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...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
type pkgdashServiceServer struct {
|
||||
PkgdashServiceServer
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) ListPackage(ctx context.Context, req *ListPackageReq, rsp *ListPackageRsp) error {
|
||||
return h.PkgdashServiceServer.ListPackage(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) UpdatePackage(ctx context.Context, req *UpdatePackageReq, rsp *UpdatePackageRsp) error {
|
||||
return h.PkgdashServiceServer.UpdatePackage(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) AddComment(ctx context.Context, req *AddCommentReq, rsp *AddCommentRsp) error {
|
||||
return h.PkgdashServiceServer.AddComment(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) AddPackage(ctx context.Context, req *AddPackageReq, rsp *AddPackageRsp) error {
|
||||
return h.PkgdashServiceServer.AddPackage(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func (h *pkgdashServiceServer) GetModule(ctx context.Context, req *GetModuleReq, rsp *GetModuleRsp) error {
|
||||
return h.PkgdashServiceServer.GetModule(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func RegisterPkgdashServiceServer(s server.Server, sh PkgdashServiceServer, opts ...options.Option) error {
|
||||
type pkgdashService interface {
|
||||
ListPackage(ctx context.Context, req *ListPackageReq, rsp *ListPackageRsp) error
|
||||
UpdatePackage(ctx context.Context, req *UpdatePackageReq, rsp *UpdatePackageRsp) error
|
||||
AddComment(ctx context.Context, req *AddCommentReq, rsp *AddCommentRsp) error
|
||||
AddPackage(ctx context.Context, req *AddPackageReq, rsp *AddPackageRsp) error
|
||||
GetModule(ctx context.Context, req *GetModuleReq, rsp *GetModuleRsp) error
|
||||
}
|
||||
type PkgdashService struct {
|
||||
pkgdashService
|
||||
}
|
||||
h := &pkgdashServiceServer{sh}
|
||||
var nopts []options.Option
|
||||
nopts = append(nopts, v4.HandlerEndpoints(PkgdashServiceServerEndpoints))
|
||||
return s.Handle(&PkgdashService{h}, append(nopts, opts...)...)
|
||||
}
|
Reference in New Issue
Block a user