Skip to content

Commit 8287214

Browse files
authored
feat: support package loader (#186)
1 parent 94e81ae commit 8287214

File tree

23 files changed

+417
-76
lines changed

23 files changed

+417
-76
lines changed

.github/workflows/license.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@v3
2929
- name: Run license check
30-
run: ./license-checker/license-checker.sh
30+
run: make license

admin/client/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
77

88
- API version: 1.0.0
99
- Package version: 1.0.0
10+
- Generator version: 7.6.0
1011
- Build package: org.openapitools.codegen.languages.GoClientCodegen
1112
For more information, please visit [https://github.com/FunctionStream](https://github.com/FunctionStream)
1213

@@ -22,7 +23,7 @@ go get golang.org/x/net/context
2223
Put the package under your project folder and add the following in import:
2324

2425
```go
25-
import adminclient "github.com/functionstream/functionstream/admin/client"
26+
import adminclient "github.com/functionstream/function-stream/admin/client"
2627
```
2728

2829
To use a proxy, set the environment variable `HTTP_PROXY`:

admin/client/client.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

admin/client/docs/ModelFunction.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Name | Type | Description | Notes
77
**Config** | Pointer to **map[string]string** | | [optional]
88
**Name** | **string** | |
99
**Namespace** | Pointer to **string** | | [optional]
10+
**Package** | **string** | |
1011
**Replicas** | **int32** | |
1112
**Runtime** | [**ModelRuntimeConfig**](ModelRuntimeConfig.md) | |
1213
**Sink** | [**ModelTubeConfig**](ModelTubeConfig.md) | |
@@ -16,7 +17,7 @@ Name | Type | Description | Notes
1617

1718
### NewModelFunction
1819

19-
`func NewModelFunction(name string, replicas int32, runtime ModelRuntimeConfig, sink ModelTubeConfig, source []ModelTubeConfig, ) *ModelFunction`
20+
`func NewModelFunction(name string, package_ string, replicas int32, runtime ModelRuntimeConfig, sink ModelTubeConfig, source []ModelTubeConfig, ) *ModelFunction`
2021

2122
NewModelFunction instantiates a new ModelFunction object
2223
This constructor will assign default values to properties that have it defined,
@@ -101,6 +102,26 @@ SetNamespace sets Namespace field to given value.
101102

102103
HasNamespace returns a boolean if a field has been set.
103104

105+
### GetPackage
106+
107+
`func (o *ModelFunction) GetPackage() string`
108+
109+
GetPackage returns the Package field if non-nil, zero value otherwise.
110+
111+
### GetPackageOk
112+
113+
`func (o *ModelFunction) GetPackageOk() (*string, bool)`
114+
115+
GetPackageOk returns a tuple with the Package field if it's non-nil, zero value otherwise
116+
and a boolean to check if the value has been set.
117+
118+
### SetPackage
119+
120+
`func (o *ModelFunction) SetPackage(v string)`
121+
122+
SetPackage sets Package field to given value.
123+
124+
104125
### GetReplicas
105126

106127
`func (o *ModelFunction) GetReplicas() int32`

admin/client/model_model_function.go

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

admin/client/utils.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apidocs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@
336336
"model.Function": {
337337
"required": [
338338
"name",
339+
"package",
339340
"runtime",
340341
"source",
341342
"sink",
@@ -354,6 +355,9 @@
354355
"namespace": {
355356
"type": "string"
356357
},
358+
"package": {
359+
"type": "string"
360+
},
357361
"replicas": {
358362
"type": "integer",
359363
"format": "int32"

benchmark/bench_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"testing"
2626
"time"
2727

28+
"github.com/functionstream/function-stream/common/config"
29+
2830
"github.com/functionstream/function-stream/fs/api"
2931
"github.com/functionstream/function-stream/fs/runtime/wazero"
3032

@@ -117,11 +119,11 @@ func BenchmarkStressForBasicFuncWithMemoryQueue(b *testing.B) {
117119

118120
s, err := server.NewServer(
119121
server.WithRuntimeFactoryBuilder(common.WASMRuntime,
120-
func(configMap common.ConfigMap) (api.FunctionRuntimeFactory, error) {
122+
func(configMap config.ConfigMap) (api.FunctionRuntimeFactory, error) {
121123
return wazero.NewWazeroFunctionRuntimeFactory(), nil
122124
}),
123125
server.WithTubeFactoryBuilder(common.MemoryTubeType,
124-
func(configMap common.ConfigMap) (contube.TubeFactory, error) {
126+
func(configMap config.ConfigMap) (contube.TubeFactory, error) {
125127
return memoryQueueFactory, nil
126128
}),
127129
)

common/config.go renamed to common/config/config.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package common
17+
package config
1818

1919
// ConfigMap is a custom type that represents a map where keys are strings and values are of any type.
2020
// Since Viper is not case-sensitive, we use '-' to separate words in all field names in the config map.
@@ -24,3 +24,14 @@ package common
2424
// - `socket-path` refers to the path of the socket.
2525
// - `pulsar-url` refers to the URL of the Pulsar service.
2626
type ConfigMap map[string]interface{}
27+
28+
// MergeConfig merges multiple ConfigMap into one
29+
func MergeConfig(configs ...ConfigMap) ConfigMap {
30+
result := ConfigMap{}
31+
for _, config := range configs {
32+
for k, v := range config {
33+
result[k] = v
34+
}
35+
}
36+
return result
37+
}

common/errors.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ package common
1919
import "fmt"
2020

2121
var (
22-
ErrorFunctionNotFound = fmt.Errorf("function not found")
23-
ErrorFunctionExists = fmt.Errorf("function already exists")
24-
ErrorRuntimeFactoryNotFound = fmt.Errorf("runtime factory not found")
25-
ErrorTubeFactoryNotFound = fmt.Errorf("tube factory not found")
22+
ErrorFunctionNotFound = fmt.Errorf("function not found")
23+
ErrorFunctionExists = fmt.Errorf("function already exists")
24+
ErrorFunctionUnsupportedRuntime = fmt.Errorf("function does not support runtime")
25+
ErrorRuntimeFactoryNotFound = fmt.Errorf("runtime factory not found")
26+
ErrorTubeFactoryNotFound = fmt.Errorf("tube factory not found")
27+
ErrorPackageNoSupportedRuntime = fmt.Errorf("package does not support any runtime")
2628
)

0 commit comments

Comments
 (0)