wip normalize
parent
c84d80e8d3
commit
3c62411927
47
config.go
47
config.go
|
|
@ -13,26 +13,27 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Port int
|
Port int
|
||||||
Debug bool
|
Debug bool
|
||||||
InitializeSlack bool
|
InitializeSlack bool
|
||||||
SlackToken string
|
SlackToken string
|
||||||
SlackChannels []string
|
SlackChannels []string
|
||||||
DriverConn string
|
DriverConn string
|
||||||
BasicAuthUser string
|
BasicAuthUser string
|
||||||
BasicAuthPassword string
|
BasicAuthPassword string
|
||||||
FillWithTestdata bool
|
FillWithTestdata bool
|
||||||
OllamaURL string
|
OllamaURL string
|
||||||
OllamaModel string
|
OllamaModel string
|
||||||
LocalCheckpoint string
|
LocalCheckpoint string
|
||||||
LocalTokenizer string
|
LocalTokenizer string
|
||||||
AssetPattern string
|
AssetPattern string
|
||||||
DatacenterPattern string
|
DatacenterPattern string
|
||||||
EventNamePattern string
|
EventNamePattern string
|
||||||
driver Driver
|
driver Driver
|
||||||
ai AI
|
ai AI
|
||||||
slackToMessagePipeline Pipeline
|
slackToMessagePipeline Pipeline
|
||||||
messageToPersistencePipeline Pipeline
|
messageToPersistencePipeline Pipeline
|
||||||
|
persistenceToNormalizedPipeline Pipeline
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -138,5 +139,11 @@ func newConfigFromEnv(ctx context.Context, getEnv func(string) string) (Config,
|
||||||
}
|
}
|
||||||
result.messageToPersistencePipeline = messageToPersistencePipeline
|
result.messageToPersistencePipeline = messageToPersistencePipeline
|
||||||
|
|
||||||
|
persistenceToNormalizedPipeline, err := NewPersistenceToNormalizedPipeline(ctx, result)
|
||||||
|
if err != nil {
|
||||||
|
return Config{}, err
|
||||||
|
}
|
||||||
|
result.persistenceToNormalizedPipeline = persistenceToNormalizedPipeline
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
main.go
6
main.go
|
|
@ -36,7 +36,11 @@ func run(ctx context.Context, cfg Config) error {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
case err := <-processPipelines(ctx, cfg.slackToMessagePipeline, cfg.messageToPersistencePipeline):
|
case err := <-processPipelines(ctx,
|
||||||
|
cfg.slackToMessagePipeline,
|
||||||
|
cfg.messageToPersistencePipeline,
|
||||||
|
cfg.persistenceToNormalizedPipeline,
|
||||||
|
):
|
||||||
return err
|
return err
|
||||||
case err := <-listenAndServe(ctx, cfg):
|
case err := <-listenAndServe(ctx, cfg):
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PersistenceToNormalized struct {
|
||||||
|
pipeline Pipeline
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPersistenceToNormalizedPipeline(ctx context.Context, cfg Config) (Pipeline, error) {
|
||||||
|
reader, err := NewQueue(ctx, "new_message", cfg.driver)
|
||||||
|
if err != nil {
|
||||||
|
return Pipeline{}, err
|
||||||
|
}
|
||||||
|
writer, err := NewQueue(ctx, "new_persistence", cfg.driver)
|
||||||
|
if err != nil {
|
||||||
|
return Pipeline{}, err
|
||||||
|
}
|
||||||
|
return Pipeline{
|
||||||
|
writer: writer,
|
||||||
|
reader: reader,
|
||||||
|
process: newPersistenceToNormalizedProcess(cfg.driver),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPersistenceToNormalizedProcess(driver Driver) processFunc {
|
||||||
|
return func(ctx context.Context, msg []byte) ([]byte, error) {
|
||||||
|
return nil, errors.New("not impl")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPersistenceToNormalizedProcessor(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
ctx, can := context.WithTimeout(context.Background(), time.Second*10)
|
||||||
|
defer can()
|
||||||
|
|
||||||
|
d := NewTestDriver(t)
|
||||||
|
process := newPersistenceToNormalizedProcess(d)
|
||||||
|
|
||||||
|
_, _ = ctx, process
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue