Skip to content

Commit

Permalink
feat: improve log and package loader (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertIndie authored Sep 8, 2024
1 parent 8287214 commit 88317ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions common/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
)

const (
DebugLevel int = 4
InfoLevel int = 3
WarnLevel int = 2
DebugLevel int = -1
InfoLevel int = 0 // Default log level
WarnLevel int = 1
)

type Logger struct {
Expand Down
2 changes: 1 addition & 1 deletion conf/function-stream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ tube-config:
runtime-config:
external:
socket-path: /tmp/fs.sock
function-store: ./functionsa
function-store: ./functions
14 changes: 10 additions & 4 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ func WithStateStoreLoader(loader func(c *StateStoreConfig) (api.StateStore, erro
})
}

func WithPackageLoader(packageLoader api.PackageLoader) ServerOption {
return serverOptionFunc(func(o *serverOptions) (*serverOptions, error) {
o.managerOpts = append(o.managerOpts, fs.WithPackageLoader(packageLoader))
return o, nil
})
}

func WithLogger(log *logr.Logger) ServerOption {
return serverOptionFunc(func(c *serverOptions) (*serverOptions, error) {
c.log = log
Expand Down Expand Up @@ -252,6 +259,7 @@ func NewServer(opts ...ServerOption) (*Server, error) {
options.runtimeFactoryBuilders = make(map[string]func(configMap config.ConfigMap) (api.FunctionRuntimeFactory, error))
options.runtimeConfig = make(map[string]config.ConfigMap)
options.stateStoreLoader = DefaultStateStoreLoader
options.managerOpts = []fs.ManagerOption{}
for _, o := range opts {
if o == nil {
continue
Expand All @@ -271,11 +279,9 @@ func NewServer(opts ...ServerOption) (*Server, error) {
options.httpTubeFact = contube.NewHttpTubeFactory(context.Background())
log.Info("Using the default HTTP tube factory")
}
options.managerOpts = []fs.ManagerOption{
options.managerOpts = append(options.managerOpts,
fs.WithTubeFactory("http", options.httpTubeFact),
}

options.managerOpts = append(options.managerOpts, fs.WithLogger(log.Logger))
fs.WithLogger(log.Logger))

// Config Tube Factory
if tubeFactories, err := setupFactories(options.tubeFactoryBuilders, options.tubeConfig); err == nil {
Expand Down

0 comments on commit 88317ee

Please sign in to comment.