Skip to content

Commit 8640cc6

Browse files
committed
feat(web_server_bin_cmd): add Web Service Binary Command Execution gRPC Server
BREAKING CHANGE: the `bifrost` gRPC server APIs have added `WebServerBinCMD`.`Exec` server The `protobuf` of the `bifrost` gRPC server APIs has been added as follows: Protocols of addition: ```protobuf service WebServerBinCMD { rpc Exec(ExecuteRequest) returns (ExecuteResponse) {} } message ExecuteRequest { string ServerName = 1; repeated string Args = 2; } message ExecuteResponse { bool Successful = 1; bytes Stdout = 2; bytes Stderr = 3; } ``` The `bifrost` gRPC server APIs client SDK has been added as follows: Methods of addition to Client Service Factory: ```go type Factory interface { ... WebServerBinCMD() WebServerBinCMDService } ``` Interface of addition to Client Service: ```go type WebServerBinCMDService interface { Exec(servername string, arg ...string) (isSuccessful bool, stdout, stderr string, err error) } ```
1 parent 8e44deb commit 8640cc6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+948
-133
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package v1
2+
3+
type ExecuteRequest struct {
4+
ServerName string `json:"server_name"`
5+
Args []string `json:"args"`
6+
}
7+
type ExecuteResponse struct {
8+
Successful bool `json:"successful"`
9+
StandardOutput []byte `json:"stdout"`
10+
StandardError []byte `json:"stderr"`
11+
}

api/protobuf-spec/bifrostpb/v1/bifrost.pb.go

Lines changed: 275 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protobuf-spec/bifrostpb/v1/bifrost.proto

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ service WebServerLogWatcher {
2121
rpc Watch(LogWatchRequest) returns (stream Response) {}
2222
}
2323

24+
service WebServerBinCMD {
25+
rpc Exec(ExecuteRequest) returns (ExecuteResponse) {}
26+
}
27+
2428
message Null {}
2529

2630
message ServerNames {
@@ -52,4 +56,15 @@ message LogWatchRequest {
5256
string ServerName = 1;
5357
string LogName = 2;
5458
string FilterRule =3;
59+
}
60+
61+
message ExecuteRequest {
62+
string ServerName = 1;
63+
repeated string Args = 2;
64+
}
65+
66+
message ExecuteResponse {
67+
bool Successful = 1;
68+
bytes Stdout = 2;
69+
bytes Stderr = 3;
5570
}

docs/devel/zh-CN/scope.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
| web_server_status | bifrost 中 WebServerStatus 模块相关的变更 |
88
| web_server_statistics | bifrost 中 WebServerStatistics 模块相关的变更 |
99
| web_server_log_watcher | bifrost 中 WebServerLogWatcher 模块相关的变更 |
10+
| web_server_bin_cmd | bifrost 中 WebServerBinCMD 模块相关的变更 |
11+
| resolv | bifrost 中 web服务配置解析库相关的变更 |
1012
| client | 组件gRPC客户端相关的变更 |
1113
| pkg | pkg 包的变更 |
1214
| docs | 文档类变更 |

docs/guide/zh-CN/api/error_code_generated.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,20 @@ Bifrost 系统支持的错误码列表如下:
4646
| ErrSameConfigFingerprints | 110003 | 500 | Same config fingerprint between files and configuration |
4747
| ErrConfigManagerIsRunning | 110004 | 500 | Config manager is running |
4848
| ErrConfigManagerIsNotRunning | 110005 | 500 | Config manager is not running |
49-
| ErrConfigurationNotFound | 110006 | 400 | Web server configuration not found |
50-
| ErrParserNotFound | 110007 | 500 | Parser not found |
51-
| ErrUnknownKeywordString | 110008 | 500 | Unknown keyword string |
52-
| ErrInvalidConfig | 110009 | 500 | Invalid parser.Config |
53-
| ErrParseFailed | 110010 | 500 | Config parse failed |
54-
| ErrV3ContextIndexOutOfRange | 110011 | 500 | Index of the Context's children is out of range |
55-
| ErrV3NullContextPosition | 110012 | 500 | Null Context position |
56-
| ErrV3SetFatherContextFailed | 110013 | 500 | Set father Context failed |
57-
| ErrV3OperationOnErrorContext | 110014 | 500 | Performing operations on Error Context |
58-
| ErrV3InvalidContext | 110015 | 500 | Invalid Context |
59-
| ErrV3InvalidOperation | 110016 | 500 | Invalid operation |
60-
| ErrV3ContextNotFound | 110017 | 500 | Queried context not found |
49+
| ErrWebServerNotFound | 110006 | 400 | Web server not found |
50+
| ErrConfigurationNotFound | 110007 | 400 | Web server configuration not found |
51+
| ErrParserNotFound | 110008 | 500 | Parser not found |
52+
| ErrUnknownKeywordString | 110009 | 500 | Unknown keyword string |
53+
| ErrInvalidConfig | 110010 | 500 | Invalid parser.Config |
54+
| ErrParseFailed | 110011 | 500 | Config parse failed |
55+
| ErrV3ContextIndexOutOfRange | 110012 | 500 | Index of the Context's children is out of range |
56+
| ErrV3NullContextPosition | 110013 | 500 | Null Context position |
57+
| ErrV3SetFatherContextFailed | 110014 | 500 | Set father Context failed |
58+
| ErrV3OperationOnErrorContext | 110015 | 500 | Performing operations on Error Context |
59+
| ErrV3InvalidContext | 110016 | 500 | Invalid Context |
60+
| ErrV3InvalidOperation | 110017 | 500 | Invalid operation |
61+
| ErrV3ContextNotFound | 110018 | 500 | Queried context not found |
62+
| ErrV3ConversionToContextFailed | 110019 | 500 | Conversion to context failed |
6163
| ErrStopMonitoringTimeout | 110201 | 500 | Stop monitoring timeout |
6264
| ErrMonitoringServiceSuspension | 110202 | 500 | Monitoring service suspension |
6365
| ErrMonitoringStarted | 110203 | 500 | Monitoring is already started |

internal/bifrost/endpoint/v1/endpoints.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package v1
22

33
import (
4+
"github.com/ClessLi/bifrost/internal/bifrost/endpoint/v1/web_server_bin_cmd"
45
"github.com/ClessLi/bifrost/internal/bifrost/endpoint/v1/web_server_config"
56
"github.com/ClessLi/bifrost/internal/bifrost/endpoint/v1/web_server_log_watcher"
67
"github.com/ClessLi/bifrost/internal/bifrost/endpoint/v1/web_server_statistics"
@@ -13,6 +14,7 @@ type EndpointsFactory interface {
1314
WebServerStatistics() WebServerStatisticsEndpoints
1415
WebServerStatus() WebServerStatusEndpoints
1516
WebServerLogWatcher() WebServerLogWatcherEndpoints
17+
WebServerBinCMD() WebServerBinCMDEndpoints
1618
}
1719

1820
var _ EndpointsFactory = &endpoints{}
@@ -40,3 +42,7 @@ func (e *endpoints) WebServerStatus() WebServerStatusEndpoints {
4042
func (e *endpoints) WebServerLogWatcher() WebServerLogWatcherEndpoints {
4143
return web_server_log_watcher.NewWebServerLogWatcherEndpoints(e.svc)
4244
}
45+
46+
func (e *endpoints) WebServerBinCMD() WebServerBinCMDEndpoints {
47+
return web_server_bin_cmd.NewWebServerBinCMDEndpoints(e.svc)
48+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package v1
2+
3+
import "github.com/go-kit/kit/endpoint"
4+
5+
type WebServerBinCMDEndpoints interface {
6+
EndpointExec() endpoint.Endpoint
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package web_server_bin_cmd
2+
3+
import (
4+
"context"
5+
v1 "github.com/ClessLi/bifrost/api/bifrost/v1"
6+
7+
"github.com/go-kit/kit/endpoint"
8+
"github.com/marmotedu/errors"
9+
)
10+
11+
func (w *webServerBinCMDEndpoints) EndpointExec() endpoint.Endpoint {
12+
return func(ctx context.Context, request interface{}) (response interface{}, err error) {
13+
if req, ok := request.(*v1.ExecuteRequest); ok {
14+
return w.svc.WebServerBinCMD().Exec(ctx, req)
15+
}
16+
17+
return nil, errors.Errorf("invalid get request, need *pbv1.ExecuteRequest, not %T", request)
18+
}
19+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package web_server_bin_cmd
2+
3+
import svcv1 "github.com/ClessLi/bifrost/internal/bifrost/service/v1"
4+
5+
type webServerBinCMDEndpoints struct {
6+
svc svcv1.ServiceFactory
7+
}
8+
9+
func NewWebServerBinCMDEndpoints(svc svcv1.ServiceFactory) *webServerBinCMDEndpoints {
10+
return &webServerBinCMDEndpoints{svc: svc}
11+
}

internal/bifrost/middleware/logging/logging.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ func (l *loggingService) WebServerLogWatcher() svcv1.WebServerLogWatcherService
3535
return newWebServerLogWatcherMiddleware(l.svc)
3636
}
3737

38+
func (l *loggingService) WebServerBinCMD() svcv1.WebServerBinCMDService {
39+
return newWebServerBinCMDMiddleware(l.svc)
40+
}
41+
3842
func New(svc svcv1.ServiceFactory) svcv1.ServiceFactory {
3943
once.Do(func() {
4044
logger = logV1.K()

0 commit comments

Comments
 (0)