Skip to content

Commit 88317ee

Browse files
authored
feat: improve log and package loader (#187)
1 parent 8287214 commit 88317ee

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

common/log.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525
)
2626

2727
const (
28-
DebugLevel int = 4
29-
InfoLevel int = 3
30-
WarnLevel int = 2
28+
DebugLevel int = -1
29+
InfoLevel int = 0 // Default log level
30+
WarnLevel int = 1
3131
)
3232

3333
type Logger struct {

conf/function-stream.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ tube-config:
2323
runtime-config:
2424
external:
2525
socket-path: /tmp/fs.sock
26-
function-store: ./functionsa
26+
function-store: ./functions

server/server.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ func WithStateStoreLoader(loader func(c *StateStoreConfig) (api.StateStore, erro
162162
})
163163
}
164164

165+
func WithPackageLoader(packageLoader api.PackageLoader) ServerOption {
166+
return serverOptionFunc(func(o *serverOptions) (*serverOptions, error) {
167+
o.managerOpts = append(o.managerOpts, fs.WithPackageLoader(packageLoader))
168+
return o, nil
169+
})
170+
}
171+
165172
func WithLogger(log *logr.Logger) ServerOption {
166173
return serverOptionFunc(func(c *serverOptions) (*serverOptions, error) {
167174
c.log = log
@@ -252,6 +259,7 @@ func NewServer(opts ...ServerOption) (*Server, error) {
252259
options.runtimeFactoryBuilders = make(map[string]func(configMap config.ConfigMap) (api.FunctionRuntimeFactory, error))
253260
options.runtimeConfig = make(map[string]config.ConfigMap)
254261
options.stateStoreLoader = DefaultStateStoreLoader
262+
options.managerOpts = []fs.ManagerOption{}
255263
for _, o := range opts {
256264
if o == nil {
257265
continue
@@ -271,11 +279,9 @@ func NewServer(opts ...ServerOption) (*Server, error) {
271279
options.httpTubeFact = contube.NewHttpTubeFactory(context.Background())
272280
log.Info("Using the default HTTP tube factory")
273281
}
274-
options.managerOpts = []fs.ManagerOption{
282+
options.managerOpts = append(options.managerOpts,
275283
fs.WithTubeFactory("http", options.httpTubeFact),
276-
}
277-
278-
options.managerOpts = append(options.managerOpts, fs.WithLogger(log.Logger))
284+
fs.WithLogger(log.Logger))
279285

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

0 commit comments

Comments
 (0)