Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
259b46f384 |
20
Makefile
Normal file
20
Makefile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# calculate current dir
|
||||||
|
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
docker_gen:
|
||||||
|
docker run --rm -v ${PWD}/proto/v1:/defs namely/protoc-all:1.51_2 -l go -d . -o .
|
||||||
|
|
||||||
|
# generate connectors for go and ts, docs, lint, validate from proto files
|
||||||
|
# build and push new version:
|
||||||
|
# make bp name=pb_builder version=pb_builder-0.0.1
|
||||||
|
regen:
|
||||||
|
cd ./v1 && \
|
||||||
|
protoc --go_out=./ --go_opt=paths=source_relative --go-grpc_out=./ --go-grpc_opt=paths=source_relative ./plugin.proto
|
||||||
|
|
||||||
|
#docker build \
|
||||||
|
# --file $(ROOT_DIR)/build/sdk.dockerfile \
|
||||||
|
# --tag sdk:latest $(ROOT_DIR) && \
|
||||||
|
# docker run \
|
||||||
|
# --rm \
|
||||||
|
# --volume $(ROOT_DIR)/sdk:/root/sdk \
|
||||||
|
# --name sdk_1 sdk:latest
|
||||||
13
README.md
Normal file → Executable file
13
README.md
Normal file → Executable file
@@ -1,2 +1,13 @@
|
|||||||
# proto
|
# SDK + Simple Service
|
||||||
|
|
||||||
|
## Описание
|
||||||
|
|
||||||
|
Предназначен для взаимодействия с внешними сервисами расширения.
|
||||||
|
|
||||||
|
## Генерация протофайла
|
||||||
|
Выполняем в терминале:
|
||||||
|
```shell
|
||||||
|
make regen
|
||||||
|
```
|
||||||
|
|
||||||
|
Cгенерированные файлы находятся в директории `v1`.
|
||||||
|
|||||||
@@ -226,28 +226,27 @@ func (x *ServicesOut) GetList() []string {
|
|||||||
var File_plugin_proto protoreflect.FileDescriptor
|
var File_plugin_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_plugin_proto_rawDesc = []byte{
|
var file_plugin_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0c, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09,
|
0x0a, 0x0c, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06,
|
||||||
0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x52, 0x0a, 0x06, 0x45, 0x78, 0x65,
|
0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, 0x52, 0x0a, 0x06, 0x45, 0x78, 0x65, 0x63, 0x49, 0x6e,
|
||||||
0x63, 0x49, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01,
|
0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a,
|
0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65,
|
||||||
0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d,
|
0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68,
|
||||||
0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18,
|
0x6f, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x01,
|
||||||
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x31, 0x0a,
|
0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x31, 0x0a, 0x07, 0x45, 0x78,
|
||||||
0x07, 0x45, 0x78, 0x65, 0x63, 0x4f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75,
|
0x65, 0x63, 0x4f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18,
|
||||||
0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74,
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x0e, 0x0a,
|
||||||
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64,
|
0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x0c, 0x0a,
|
||||||
0x22, 0x0c, 0x0a, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x49, 0x6e, 0x22, 0x21,
|
0x0a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x49, 0x6e, 0x22, 0x21, 0x0a, 0x0b, 0x53,
|
||||||
0x0a, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x4f, 0x75, 0x74, 0x12, 0x12, 0x0a,
|
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x4f, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69,
|
||||||
0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69, 0x73,
|
0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x32, 0x69,
|
||||||
0x74, 0x32, 0x75, 0x0a, 0x09, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x2d,
|
0x0a, 0x09, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x27, 0x0a, 0x04, 0x45,
|
||||||
0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x11, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74,
|
0x78, 0x65, 0x63, 0x12, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x45, 0x78, 0x65,
|
||||||
0x6f, 0x72, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x49, 0x6e, 0x1a, 0x12, 0x2e, 0x63, 0x6f, 0x6c, 0x6c,
|
0x63, 0x49, 0x6e, 0x1a, 0x0f, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x45, 0x78, 0x65,
|
||||||
0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x4f, 0x75, 0x74, 0x12, 0x39, 0x0a,
|
0x63, 0x4f, 0x75, 0x74, 0x12, 0x33, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
|
||||||
0x08, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x15, 0x2e, 0x63, 0x6f, 0x6c, 0x6c,
|
0x12, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||||
0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x49, 0x6e,
|
0x65, 0x73, 0x49, 0x6e, 0x1a, 0x13, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x65,
|
||||||
0x1a, 0x16, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x53, 0x65, 0x72,
|
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x4f, 0x75, 0x74, 0x42, 0x03, 0x5a, 0x01, 0x2e, 0x62, 0x06,
|
||||||
0x76, 0x69, 0x63, 0x65, 0x73, 0x4f, 0x75, 0x74, 0x42, 0x03, 0x5a, 0x01, 0x2e, 0x62, 0x06, 0x70,
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -264,16 +263,16 @@ func file_plugin_proto_rawDescGZIP() []byte {
|
|||||||
|
|
||||||
var file_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
var file_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||||
var file_plugin_proto_goTypes = []interface{}{
|
var file_plugin_proto_goTypes = []interface{}{
|
||||||
(*ExecIn)(nil), // 0: simple_plugin.ExecIn
|
(*ExecIn)(nil), // 0: plugin.ExecIn
|
||||||
(*ExecOut)(nil), // 1: simple_plugin.ExecOut
|
(*ExecOut)(nil), // 1: plugin.ExecOut
|
||||||
(*ServicesIn)(nil), // 2: simple_plugin.ServicesIn
|
(*ServicesIn)(nil), // 2: plugin.ServicesIn
|
||||||
(*ServicesOut)(nil), // 3: simple_plugin.ServicesOut
|
(*ServicesOut)(nil), // 3: plugin.ServicesOut
|
||||||
}
|
}
|
||||||
var file_plugin_proto_depIdxs = []int32{
|
var file_plugin_proto_depIdxs = []int32{
|
||||||
0, // 0: simple_plugin.Collector.Exec:input_type -> simple_plugin.ExecIn
|
0, // 0: plugin.Collector.Exec:input_type -> plugin.ExecIn
|
||||||
2, // 1: simple_plugin.Collector.Services:input_type -> simple_plugin.ServicesIn
|
2, // 1: plugin.Collector.Services:input_type -> plugin.ServicesIn
|
||||||
1, // 2: simple_plugin.Collector.Exec:output_type -> simple_plugin.ExecOut
|
1, // 2: plugin.Collector.Exec:output_type -> plugin.ExecOut
|
||||||
3, // 3: simple_plugin.Collector.Services:output_type -> simple_plugin.ServicesOut
|
3, // 3: plugin.Collector.Services:output_type -> plugin.ServicesOut
|
||||||
2, // [2:4] is the sub-list for method output_type
|
2, // [2:4] is the sub-list for method output_type
|
||||||
0, // [0:2] is the sub-list for method input_type
|
0, // [0:2] is the sub-list for method input_type
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package collector;
|
package plugin;
|
||||||
|
|
||||||
option go_package = ".";
|
option go_package = ".";
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func NewCollectorClient(cc grpc.ClientConnInterface) CollectorClient {
|
|||||||
|
|
||||||
func (c *collectorClient) Exec(ctx context.Context, in *ExecIn, opts ...grpc.CallOption) (*ExecOut, error) {
|
func (c *collectorClient) Exec(ctx context.Context, in *ExecIn, opts ...grpc.CallOption) (*ExecOut, error) {
|
||||||
out := new(ExecOut)
|
out := new(ExecOut)
|
||||||
err := c.cc.Invoke(ctx, "/simple_plugin.Collector/Exec", in, out, opts...)
|
err := c.cc.Invoke(ctx, "/plugin.Collector/Exec", in, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ func (c *collectorClient) Exec(ctx context.Context, in *ExecIn, opts ...grpc.Cal
|
|||||||
|
|
||||||
func (c *collectorClient) Services(ctx context.Context, in *ServicesIn, opts ...grpc.CallOption) (*ServicesOut, error) {
|
func (c *collectorClient) Services(ctx context.Context, in *ServicesIn, opts ...grpc.CallOption) (*ServicesOut, error) {
|
||||||
out := new(ServicesOut)
|
out := new(ServicesOut)
|
||||||
err := c.cc.Invoke(ctx, "/simple_plugin.Collector/Services", in, out, opts...)
|
err := c.cc.Invoke(ctx, "/plugin.Collector/Services", in, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ func _Collector_Exec_Handler(srv interface{}, ctx context.Context, dec func(inte
|
|||||||
}
|
}
|
||||||
info := &grpc.UnaryServerInfo{
|
info := &grpc.UnaryServerInfo{
|
||||||
Server: srv,
|
Server: srv,
|
||||||
FullMethod: "/simple_plugin.Collector/Exec",
|
FullMethod: "/plugin.Collector/Exec",
|
||||||
}
|
}
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return srv.(CollectorServer).Exec(ctx, req.(*ExecIn))
|
return srv.(CollectorServer).Exec(ctx, req.(*ExecIn))
|
||||||
@@ -112,7 +112,7 @@ func _Collector_Services_Handler(srv interface{}, ctx context.Context, dec func(
|
|||||||
}
|
}
|
||||||
info := &grpc.UnaryServerInfo{
|
info := &grpc.UnaryServerInfo{
|
||||||
Server: srv,
|
Server: srv,
|
||||||
FullMethod: "/simple_plugin.Collector/Services",
|
FullMethod: "/plugin.Collector/Services",
|
||||||
}
|
}
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return srv.(CollectorServer).Services(ctx, req.(*ServicesIn))
|
return srv.(CollectorServer).Services(ctx, req.(*ServicesIn))
|
||||||
@@ -124,7 +124,7 @@ func _Collector_Services_Handler(srv interface{}, ctx context.Context, dec func(
|
|||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
var Collector_ServiceDesc = grpc.ServiceDesc{
|
var Collector_ServiceDesc = grpc.ServiceDesc{
|
||||||
ServiceName: "simple_plugin.Collector",
|
ServiceName: "plugin.Collector",
|
||||||
HandlerType: (*CollectorServer)(nil),
|
HandlerType: (*CollectorServer)(nil),
|
||||||
Methods: []grpc.MethodDesc{
|
Methods: []grpc.MethodDesc{
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user