add overlooked invoke function to scripts; fix typos in doc
This commit is contained in:
1 parent
a5b9f05d05
commit
6d064d5e02
7 files changed
+31
-28
No files matched your search
@@ -1,3 +1,5 @@
|
|||||||
|
### v2.5.4
|
||||||
|
* fix: added missing "invoke" function to scripts
|
||||||
### v2.5.3
|
### v2.5.3
|
||||||
* added "invalid script configuration" error instead of "404:Not Found" error when invalid script was requested.
|
* added "invalid script configuration" error instead of "404:Not Found" error when invalid script was requested.
|
||||||
### v2.5.2
|
### v2.5.2
|
||||||
|
|||||||
@@ -9,13 +9,12 @@ var Script scriptController
|
|||||||
|
|
||||||
type scriptController struct{}
|
type scriptController struct{}
|
||||||
|
|
||||||
// ExecuteById godoc
|
|
||||||
// @Tags script
|
// @Tags script
|
||||||
// @Summary Выполнить скрипт под конкректным ID
|
// @Summary Выполнить скрипт под конкретным ID
|
||||||
// @Description Возвращает результат выполнения скрипта и ошибку (если есть)
|
// @Description Возвращает результат выполнения скрипта и ошибку (если есть)
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body domain.ExecuteByIdRequest true "Идентифиактор скрипта"
|
// @Param body body domain.ExecuteByIdRequest true "идентификатор скрипта"
|
||||||
// @Success 200 {object} domain.ScriptResp
|
// @Success 200 {object} domain.ScriptResp
|
||||||
// @Failure 404 {object} structure.GrpcError
|
// @Failure 404 {object} structure.GrpcError
|
||||||
// @Router /script/execute_by_id [POST].
|
// @Router /script/execute_by_id [POST].
|
||||||
@@ -23,7 +22,6 @@ func (c scriptController) ExecuteById(req domain.ExecuteByIdRequest) (*domain.Sc
|
|||||||
return service.Script.ExecuteById(req)
|
return service.Script.ExecuteById(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute godoc
|
|
||||||
// @Tags script
|
// @Tags script
|
||||||
// @Summary Выполнить скрипт без учёта идентификатора
|
// @Summary Выполнить скрипт без учёта идентификатора
|
||||||
// @Description Возвращает результат выполнения скрипта и ошибку (если есть)
|
// @Description Возвращает результат выполнения скрипта и ошибку (если есть)
|
||||||
@@ -36,26 +34,24 @@ func (c scriptController) Execute(req domain.ExecuteRequest) *domain.ScriptResp
|
|||||||
return service.Script.Execute(req)
|
return service.Script.Execute(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BatchExecute godoc
|
|
||||||
// @Tags script
|
// @Tags script
|
||||||
// @Summary Выполнить набор скриптов под конкретными ID
|
// @Summary Выполнить набор скриптов под конкретными ID
|
||||||
// @Description Возвращает результат выполнения скриптов и ошибок (если есть)
|
// @Description Возвращает результат выполнения скриптов и ошибок (если есть)
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body []domain.ExecuteByIdRequest true "Набор идентфикаторов и аргументов"
|
// @Param body body []domain.ExecuteByIdRequest true "Набор идентификаторов и аргументов"
|
||||||
// @Success 200 {array} domain.ScriptResp
|
// @Success 200 {array} domain.ScriptResp
|
||||||
// @Router /script/batch_execute [POST].
|
// @Router /script/batch_execute [POST].
|
||||||
func (c scriptController) BatchExecute(req []domain.ExecuteByIdRequest) []domain.ScriptResp {
|
func (c scriptController) BatchExecute(req []domain.ExecuteByIdRequest) []domain.ScriptResp {
|
||||||
return service.Script.BatchExecute(req)
|
return service.Script.BatchExecute(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BatchExecuteById godoc
|
|
||||||
// @Tags script
|
// @Tags script
|
||||||
// @Summary Выполнить набор скриптов под конкретными ID с идентичным аргументом для всех
|
// @Summary Выполнить набор скриптов под конкретными ID с идентичным аргументом для всех
|
||||||
// @Description Возвращает результат выполнения скриптов и ошибок (если есть)
|
// @Description Возвращает результат выполнения скриптов и ошибок (если есть)
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body domain.BatchExecuteByIdsRequest true "Набор идентфикаторов и единый аргумент"
|
// @Param body body domain.BatchExecuteByIdsRequest true "Набор идентификаторов и единый аргумент"
|
||||||
// @Success 200 {array} domain.ScriptResp
|
// @Success 200 {array} domain.ScriptResp
|
||||||
// @Router /script/batch_execute_by_ids [POST].
|
// @Router /script/batch_execute_by_ids [POST].
|
||||||
func (c scriptController) BatchExecuteById(req domain.BatchExecuteByIdsRequest) []domain.ScriptResp {
|
func (c scriptController) BatchExecuteById(req domain.BatchExecuteByIdsRequest) []domain.ScriptResp {
|
||||||
|
|||||||
+6
-6
@@ -1,6 +1,6 @@
|
|||||||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
||||||
// This file was generated by swaggo/swag at
|
// This file was generated by swaggo/swag at
|
||||||
// 2020-09-02 11:50:09.819512899 +0300 MSK m=+24.009697076
|
// 2021-03-02 15:27:22.602367553 +0300 MSK m=+31.469395847
|
||||||
|
|
||||||
package docs
|
package docs
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ var doc = `{
|
|||||||
"summary": "Выполнить набор скриптов под конкретными ID",
|
"summary": "Выполнить набор скриптов под конкретными ID",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "Набор идентфикаторов и аргументов",
|
"description": "Набор идентификаторов и аргументов",
|
||||||
"name": "body",
|
"name": "body",
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
@@ -78,7 +78,7 @@ var doc = `{
|
|||||||
"summary": "Выполнить набор скриптов под конкретными ID с идентичным аргументом для всех",
|
"summary": "Выполнить набор скриптов под конкретными ID с идентичным аргументом для всех",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "Набор идентфикаторов и единый аргумент",
|
"description": "Набор идентификаторов и единый аргумент",
|
||||||
"name": "body",
|
"name": "body",
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
@@ -146,10 +146,10 @@ var doc = `{
|
|||||||
"tags": [
|
"tags": [
|
||||||
"script"
|
"script"
|
||||||
],
|
],
|
||||||
"summary": "Выполнить скрипт под конкректным ID",
|
"summary": "Выполнить скрипт под конкретным ID",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "Идентифиактор скрипта",
|
"description": "идентификатор скрипта",
|
||||||
"name": "body",
|
"name": "body",
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
@@ -271,7 +271,7 @@ var SwaggerInfo = docs.SwaggerInfo{
|
|||||||
BasePath: "/api/script",
|
BasePath: "/api/script",
|
||||||
Schemes: []string{},
|
Schemes: []string{},
|
||||||
Title: "isp-script-service",
|
Title: "isp-script-service",
|
||||||
Description: "Сервис для обработка и выполения JavaScript скриптов",
|
Description: "Сервис для обработки и выполнения JavaScript скриптов",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
+7
-6
@@ -58,7 +58,7 @@ definitions:
|
|||||||
host: localhost:9000
|
host: localhost:9000
|
||||||
info:
|
info:
|
||||||
contact: {}
|
contact: {}
|
||||||
description: Сервис для обработка и выполения JavaScript скриптов
|
description: Сервис для обработки и выполнения JavaScript скриптов
|
||||||
license:
|
license:
|
||||||
name: GNU GPL v3.0
|
name: GNU GPL v3.0
|
||||||
title: isp-script-service
|
title: isp-script-service
|
||||||
@@ -70,7 +70,7 @@ paths:
|
|||||||
- application/json
|
- application/json
|
||||||
description: Возвращает результат выполнения скриптов и ошибок (если есть)
|
description: Возвращает результат выполнения скриптов и ошибок (если есть)
|
||||||
parameters:
|
parameters:
|
||||||
- description: Набор идентфикаторов и аргументов
|
- description: Набор идентификаторов и аргументов
|
||||||
in: body
|
in: body
|
||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
@@ -96,7 +96,7 @@ paths:
|
|||||||
- application/json
|
- application/json
|
||||||
description: Возвращает результат выполнения скриптов и ошибок (если есть)
|
description: Возвращает результат выполнения скриптов и ошибок (если есть)
|
||||||
parameters:
|
parameters:
|
||||||
- description: Набор идентфикаторов и единый аргумент
|
- description: Набор идентификаторов и единый аргумент
|
||||||
in: body
|
in: body
|
||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
@@ -111,7 +111,8 @@ paths:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/definitions/domain.ScriptResp'
|
$ref: '#/definitions/domain.ScriptResp'
|
||||||
type: array
|
type: array
|
||||||
summary: Выполнить набор скриптов под конкретными ID с идентичным аргументом для всех
|
summary: Выполнить набор скриптов под конкретными ID с идентичным аргументом
|
||||||
|
для всех
|
||||||
tags:
|
tags:
|
||||||
- script
|
- script
|
||||||
/script/execute:
|
/script/execute:
|
||||||
@@ -142,7 +143,7 @@ paths:
|
|||||||
- application/json
|
- application/json
|
||||||
description: Возвращает результат выполнения скрипта и ошибку (если есть)
|
description: Возвращает результат выполнения скрипта и ошибку (если есть)
|
||||||
parameters:
|
parameters:
|
||||||
- description: Идентифиактор скрипта
|
- description: идентификатор скрипта
|
||||||
in: body
|
in: body
|
||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
@@ -159,7 +160,7 @@ paths:
|
|||||||
description: Not Found
|
description: Not Found
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/structure.GrpcError'
|
$ref: '#/definitions/structure.GrpcError'
|
||||||
summary: Выполнить скрипт под конкректным ID
|
summary: Выполнить скрипт под конкретным ID
|
||||||
tags:
|
tags:
|
||||||
- script
|
- script
|
||||||
swagger: "2.0"
|
swagger: "2.0"
|
||||||
@@ -24,13 +24,15 @@ var version = "1.0.0"
|
|||||||
|
|
||||||
// @title isp-script-service
|
// @title isp-script-service
|
||||||
// @version 1.0.0
|
// @version 1.0.0
|
||||||
// @description Сервис для обработка и выполения JavaScript скриптов
|
// @description Сервис для обработки и выполнения JavaScript скриптов
|
||||||
|
|
||||||
// @license.name GNU GPL v3.0
|
// @license.name GNU GPL v3.0
|
||||||
|
|
||||||
// @host localhost:9000
|
// @host localhost:9000
|
||||||
// @BasePath /api/script
|
// @BasePath /api/script
|
||||||
|
|
||||||
|
//go:generate swag init --parseDependency
|
||||||
|
//go:generate rm -f docs/swagger.json
|
||||||
func main() {
|
func main() {
|
||||||
bootstrap.
|
bootstrap.
|
||||||
ServiceBootstrap(&conf.Configuration{}, &conf.RemoteConfig{}).
|
ServiceBootstrap(&conf.Configuration{}, &conf.RemoteConfig{}).
|
||||||
|
|||||||
+8
-6
@@ -5,16 +5,16 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/integration-system/isp-lib/v2/scripts"
|
|
||||||
log_code "isp-script-service/codes"
|
|
||||||
"isp-script-service/conf"
|
|
||||||
"isp-script-service/domain"
|
|
||||||
|
|
||||||
"github.com/integration-system/isp-lib/v2/config"
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
"github.com/integration-system/isp-lib/v2/scripts"
|
||||||
log "github.com/integration-system/isp-log"
|
log "github.com/integration-system/isp-log"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
log_code "isp-script-service/codes"
|
||||||
|
"isp-script-service/conf"
|
||||||
|
"isp-script-service/domain"
|
||||||
|
"isp-script-service/router"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Script = &scriptService{
|
var Script = &scriptService{
|
||||||
@@ -120,7 +120,9 @@ func (s *scriptService) executeScript(scr CompiledScript, arg interface{}) *doma
|
|||||||
|
|
||||||
cfg := config.GetRemote().(*conf.RemoteConfig)
|
cfg := config.GetRemote().(*conf.RemoteConfig)
|
||||||
response, err := s.scriptEngine.Execute(scr.Script, arg,
|
response, err := s.scriptEngine.Execute(scr.Script, arg,
|
||||||
scripts.WithScriptTimeout(time.Duration(cfg.ScriptExecutionTimeoutMs)*time.Millisecond))
|
scripts.WithScriptTimeout(time.Duration(cfg.ScriptExecutionTimeoutMs)*time.Millisecond),
|
||||||
|
scripts.WithSet("invoke", router.Invoke),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return s.respError(err, domain.ErrorRunTime)
|
return s.respError(err, domain.ErrorRunTime)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user