Skip to content
Merged
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
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,18 @@ gen_rest_client:
rm -r restclient/go.mod restclient/go.sum restclient/.travis.yml restclient/.openapi-generator-ignore \
restclient/git_push.sh restclient/.openapi-generator restclient/api restclient/test

proto:
for PROTO_FILE in $$(find . -name '*.proto'); do \
echo "generating codes for $$PROTO_FILE"; \
protoc \
--go_out=. \
--go_opt paths=source_relative \
--plugin protoc-gen-go="${GOPATH}/bin/protoc-gen-go" \
--go-grpc_out=. \
--go-grpc_opt paths=source_relative \
--plugin protoc-gen-go-grpc="${GOPATH}/bin/protoc-gen-go-grpc" \
$$PROTO_FILE; \
done

license:
./license-checker/license-checker.sh
21 changes: 14 additions & 7 deletions benchmark/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import (
)

func BenchmarkStressForBasicFunc(b *testing.B) {
s := server.New(server.LoadConfigFromEnv())
s, err := server.NewServer(server.LoadConfigFromEnv())
if err != nil {
b.Fatal(err)
}
svrCtx, svrCancel := context.WithCancel(context.Background())
go s.Run(svrCtx)
defer func() {
Expand Down Expand Up @@ -103,14 +106,18 @@ func BenchmarkStressForBasicFunc(b *testing.B) {
func BenchmarkStressForBasicFuncWithMemoryQueue(b *testing.B) {
memoryQueueFactory := contube.NewMemoryQueueFactory(context.Background())

svrConf := &fs.Config{
svrConf := &common.Config{
ListenAddr: common.DefaultAddr,
TubeBuilder: func(ctx context.Context, config *fs.Config) (contube.TubeFactory, error) {
return memoryQueueFactory, nil
},
}

s := server.New(svrConf)
fm, err := fs.NewFunctionManager(fs.WithDefaultTubeFactory(memoryQueueFactory))
if err != nil {
b.Fatal(err)
}
s, err := server.NewServer(svrConf, server.WithFunctionManager(fm))
if err != nil {
b.Fatal(err)
}
svrCtx, svrCancel := context.WithCancel(context.Background())
go s.Run(svrCtx)
defer func() {
Expand All @@ -130,7 +137,7 @@ func BenchmarkStressForBasicFuncWithMemoryQueue(b *testing.B) {
Output: outputTopic,
Replicas: &replicas,
},
QueueBuilder: func(ctx context.Context, c *fs.Config) (contube.TubeFactory, error) {
QueueBuilder: func(ctx context.Context, c *common.Config) (contube.TubeFactory, error) {
return memoryQueueFactory, nil
},
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/server/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ var (

func exec(*cobra.Command, []string) {
common.RunProcess(func() (io.Closer, error) {
s := server.New(server.LoadConfigFromEnv())
s, err := server.NewServer(server.LoadConfigFromEnv())
if err != nil {
return nil, err
}
go s.Run(context.Background())
return s, nil
})
Expand Down
5 changes: 4 additions & 1 deletion cmd/standalone/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ var (

func exec(*cobra.Command, []string) {
common.RunProcess(func() (io.Closer, error) {
s := server.New(server.LoadStandaloneConfigFromEnv())
s, err := server.NewServer(server.LoadStandaloneConfigFromEnv())
if err != nil {
return nil, err
}
go s.Run(context.Background())
return s, nil
})
Expand Down
15 changes: 4 additions & 11 deletions fs/config.go → common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@
* limitations under the License.
*/

package fs

import (
"context"
"github.com/functionstream/functionstream/fs/contube"
)

type TubeBuilder func(ctx context.Context, config *Config) (contube.TubeFactory, error)
package common

// Config is a struct that holds the configuration for a function stream.
type Config struct {
ListenAddr string // ListenAddr is the address that the function stream REST service will listen on.
PulsarURL string // PulsarURL is the URL of the Pulsar service. It's used for the pulsar_tube
TubeBuilder TubeBuilder // TubeBuilder is a function that will be used to build the tube.
ListenAddr string // ListenAddr is the address that the function stream REST service will listen on.
PulsarURL string // PulsarURL is the URL of the Pulsar service. It's used for the pulsar_tube
TubeType string
}
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package common

const (
PulsarTubeType = "pulsar"
MemoryTubeType = "memory"

DefaultAddr = "localhost:7300"
DefaultPulsarURL = "pulsar://localhost:6650"
Expand Down
10 changes: 7 additions & 3 deletions common/model/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
package model

type Function struct {
Name string
Archive string
Inputs []string
Name string
Archive string
Source map[string]any
Sink map[string]any
// Deprecate
Inputs []string
// Deprecate
Output string
Config map[string]string
Replicas int32
Expand Down
35 changes: 35 additions & 0 deletions fs/api/instance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2024 Function Stream Org.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package api

import (
"github.com/functionstream/functionstream/common/model"
"github.com/functionstream/functionstream/fs/contube"
"golang.org/x/net/context"
)

type FunctionInstance interface {
Context() context.Context
Definition() *model.Function
Stop()
Run(factory FunctionRuntimeFactory)
WaitForReady() <-chan error
}

type FunctionInstanceFactory interface {
NewFunctionInstance(f *model.Function, queueFactory contube.TubeFactory, i int32) FunctionInstance
}
31 changes: 31 additions & 0 deletions fs/api/runtime.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2024 Function Stream Org.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package api

import (
"github.com/functionstream/functionstream/fs/contube"
)

type FunctionRuntime interface {
WaitForReady() <-chan error
Call(e contube.Record) (contube.Record, error)
Stop()
}

type FunctionRuntimeFactory interface {
NewFunctionRuntime(instance FunctionInstance) (FunctionRuntime, error)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
147 changes: 0 additions & 147 deletions fs/instance.go

This file was deleted.

Loading