Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cmd/keygen/keygen
cmd/keyforge/keyforge
cmd/bootstrap-limiter/bootstrap-limiter

./tmp-*
dist/
runtime/
*.env
Expand Down
72 changes: 59 additions & 13 deletions api/b7s-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ paths:
description: Invalid execution request
'500':
description: Internal server error


/api/v1/functions/requests/result:
post:
Expand All @@ -111,6 +110,30 @@ paths:
'500':
description: Internal server error

/api/v1/functions/execute/batch/result:
post:
tags:
- functions
summary: Get the result of a Batch Execution Request
description: Get the result of a Batch Execution Request
operationId: batchExecutionResult
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/BatchResultRequest'
required: true
responses:
'200':
description: Batch Execution result retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/BatchExecutionResult'
'400':
description: Invalid request
'500':
description: Internal server error

/api/v1/functions/install:
post:
Expand Down Expand Up @@ -158,9 +181,18 @@ components:
example: hello-world.wasm
description: Name of the WASM file to execute
x-go-type-skip-optional-pointer: true
parameters:
arguments:
type: array
description: CLI arguments for the Bless Function
items:
type: string
example:
- [ "--arg", "first-invocation-argument", "other arguments..." ]
x-go-type-skip-optional-pointer: true
parameters:
type: array
deprecated: true
x-deprecated-reason: Use the `arguments` field.
items:
$ref: '#/components/schemas/ExecutionParameter'
example:
Expand Down Expand Up @@ -545,7 +577,6 @@ components:
- [ "--arg", "second-invocation-argument", "other arguments..." ]
- [ "--arg", "third-invocation-argument", "other arguments..." ]
x-go-type-skip-optional-pointer: true


TemplateExecutionRequest:
required:
Expand All @@ -567,8 +598,16 @@ components:
config:
$ref: '#/components/schemas/ExecutionConfig'


BatchExecutionResponse:
type: object
properties:
request_id:
description: ID of the Execution Request
type: string
example: b6fbbc5e-1d16-4ea9-b557-51f4a6ab565c
x-go-type-skip-optional-pointer: true

BatchExecutionResult:
type: object
properties:
code:
Expand All @@ -585,15 +624,15 @@ components:
description: If the Batch Execution Request failed, this message might have more info about the error
type: string
x-go-type-skip-optional-pointer: true
strands:
chunks:
description: Results of the execution of the Batch Request, executed by different nodes
x-go-type-skip-optional-pointer: true
additionalProperties:
$ref: '#/components/schemas/StrandResults'
$ref: '#/components/schemas/ChunkResults'

StrandResults:
ChunkResults:
type: object
x-go-type: response.NodeStrandResults
x-go-type: response.NodeChunkResults
x-go-type-import:
path: github.com/blessnetwork/b7s/models/response
properties:
Expand Down Expand Up @@ -634,8 +673,15 @@ components:
type: object
x-go-type-skip-optional-pointer: true






BatchResultRequest:
description: Get the result of an Batch Execution Request, identified by the request ID
type: object
required:
- id
x-go-type-skip-optional-pointer: true
properties:
id:
description: ID of the Batch Execution Request
type: string
example: b6fbbc5e-1d16-4ea9-b557-51f4a6ab565c
x-go-type-skip-optional-pointer: true
31 changes: 31 additions & 0 deletions api/batch_result.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package api

import (
"fmt"
"net/http"

"github.com/labstack/echo/v4"
)

func (a *API) BatchExecutionResult(ctx echo.Context) error {

var req BatchResultRequest
err := ctx.Bind(&req)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("could not unpack request: %w", err))
}

res, err := a.Node.GetBatchResults(ctx.Request().Context(), req.Id)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("could not retrieve batch execution result: %w", err))
}

out := BatchExecutionResult{
RequestId: res.RequestID,
Code: res.Code.String(),
Message: res.ErrorMessage,
Chunks: res.Chunks,
}

return ctx.JSON(http.StatusOK, out)
}
141 changes: 140 additions & 1 deletion api/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions api/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ func (a *API) ExecuteFunction(ctx echo.Context) error {
Config: req.Config,
FunctionID: req.FunctionId,
Method: req.Method,
// TODO: Init arguments here, update API models.
Arguments: req.Arguments,
}

var args []string
// Maintain backwards compatibility: if someone provided function arguments via the `parameters` field
// use them, but only if the current, newer field (arguments) was not used.
// In the future remove 'parameters' field.
if len(exr.Arguments) == 0 && len(req.Parameters) > 0 {

// Maintain backwards compatibility - if someone provided function arguments via the `parameters` field.
if len(req.Parameters) > 0 {
var args []string
for _, p := range req.Parameters {
args = append(args, p.Value)

}

exr.Arguments = args
}
exr.Arguments = args

err = exr.Valid()
if err != nil {
Expand Down
Loading