Compare commits
No commits in common. "main" and "v1.8" have entirely different histories.
4
ap.go
4
ap.go
|
@ -99,8 +99,8 @@ func (s *accessPoint) WriteWithTag(tag frame.Tag, data []byte) error {
|
||||||
f := frame.NewDataFrame()
|
f := frame.NewDataFrame()
|
||||||
f.SetCarriage(tag, data)
|
f.SetCarriage(tag, data)
|
||||||
f.SetSourceId(s.client.ClientId())
|
f.SetSourceId(s.client.ClientId())
|
||||||
log.Debugf("%s WriteWithTag: tid=%s, source_id=%s, data[%d]",
|
log.Debugf("%sWriteWithTag: tid=%s, source_id=%s, data[%d]=%# x",
|
||||||
apLogPrefix, f.TransactionId(), f.SourceId(), len(data))
|
apLogPrefix, f.TransactionId(), f.SourceId(), len(data), frame.Shortly(data))
|
||||||
return s.client.WriteFrame(f)
|
return s.client.WriteFrame(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
go.mod
14
go.mod
|
@ -3,9 +3,8 @@ module git.hpds.cc/pavement/hpds_node
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.hpds.cc/Component/network v0.0.0-20230421024959-bf7300c92a95
|
git.hpds.cc/Component/network v0.0.0-20230405091029-b109c53056fb
|
||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
github.com/quic-go/quic-go v0.33.0
|
|
||||||
github.com/stretchr/testify v1.8.0
|
github.com/stretchr/testify v1.8.0
|
||||||
github.com/u2takey/ffmpeg-go v0.4.1
|
github.com/u2takey/ffmpeg-go v0.4.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
|
@ -25,6 +24,7 @@ require (
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/quic-go/qtls-go1-19 v0.2.1 // indirect
|
github.com/quic-go/qtls-go1-19 v0.2.1 // indirect
|
||||||
github.com/quic-go/qtls-go1-20 v0.1.1 // indirect
|
github.com/quic-go/qtls-go1-20 v0.1.1 // indirect
|
||||||
|
github.com/quic-go/quic-go v0.33.0 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
||||||
github.com/u2takey/go-utils v0.3.1 // indirect
|
github.com/u2takey/go-utils v0.3.1 // indirect
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
go.uber.org/atomic v1.7.0 // indirect
|
||||||
|
@ -32,14 +32,10 @@ require (
|
||||||
go.uber.org/zap v1.23.0 // indirect
|
go.uber.org/zap v1.23.0 // indirect
|
||||||
golang.org/x/crypto v0.4.0 // indirect
|
golang.org/x/crypto v0.4.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
|
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
|
||||||
golang.org/x/image v0.1.0 // indirect
|
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
|
||||||
golang.org/x/mod v0.6.0 // indirect
|
golang.org/x/mod v0.6.0 // indirect
|
||||||
golang.org/x/net v0.5.0 // indirect
|
golang.org/x/net v0.4.0 // indirect
|
||||||
golang.org/x/sys v0.4.0 // indirect
|
golang.org/x/sys v0.3.0 // indirect
|
||||||
golang.org/x/tools v0.2.0 // indirect
|
golang.org/x/tools v0.2.0 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
//replace (
|
|
||||||
// git.hpds.cc/Component/network => ../network
|
|
||||||
//)
|
|
||||||
|
|
7
mq.go
7
mq.go
|
@ -5,7 +5,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.hpds.cc/Component/network/metadata"
|
"git.hpds.cc/Component/network/metadata"
|
||||||
"git.hpds.cc/Component/network/router"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.hpds.cc/Component/network"
|
"git.hpds.cc/Component/network"
|
||||||
|
@ -140,11 +139,7 @@ func (z *messageQueue) ConfigWorkflow(conf string) error {
|
||||||
func (z *messageQueue) configWorkflow(config *config.WorkflowConfig) error {
|
func (z *messageQueue) configWorkflow(config *config.WorkflowConfig) error {
|
||||||
z.wfc = config
|
z.wfc = config
|
||||||
z.server.ConfigMetadataBuilder(metadata.DefaultBuilder())
|
z.server.ConfigMetadataBuilder(metadata.DefaultBuilder())
|
||||||
funcList := make([]string, len(config.Functions))
|
z.server.ConfigRouter(newRouter(config.Functions))
|
||||||
for k, v := range config.Functions {
|
|
||||||
funcList[k] = v.Name
|
|
||||||
}
|
|
||||||
z.server.ConfigRouter(router.Default(funcList))
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,11 @@ func (z *messageQueue) init() {
|
||||||
go func() {
|
go func() {
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, syscall.SIGTERM, syscall.SIGUSR2, syscall.SIGUSR1, syscall.SIGINT)
|
signal.Notify(c, syscall.SIGTERM, syscall.SIGUSR2, syscall.SIGUSR1, syscall.SIGINT)
|
||||||
log.Infof("%sListening SIGUSR1, SIGUSR2, SIGTERM/SIGINT...", mqLogPrefix)
|
log.Printf("%sListening SIGUSR1, SIGUSR2, SIGTERM/SIGINT...", mqLogPrefix)
|
||||||
for p1 := range c {
|
for p1 := range c {
|
||||||
log.Infof("Received signal: %s", p1)
|
log.Printf("Received signal: %s", p1)
|
||||||
if p1 == syscall.SIGTERM || p1 == syscall.SIGINT {
|
if p1 == syscall.SIGTERM || p1 == syscall.SIGINT {
|
||||||
log.Infof("graceful shutting down ... %s", p1)
|
log.Printf("graceful shutting down ... %s", p1)
|
||||||
_ = z.Close()
|
_ = z.Close()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
} else if p1 == syscall.SIGUSR2 {
|
} else if p1 == syscall.SIGUSR2 {
|
||||||
|
@ -33,7 +33,7 @@ func (z *messageQueue) init() {
|
||||||
runtime.ReadMemStats(&m)
|
runtime.ReadMemStats(&m)
|
||||||
fmt.Printf("\tNumGC = %v\n", m.NumGC)
|
fmt.Printf("\tNumGC = %v\n", m.NumGC)
|
||||||
} else if p1 == syscall.SIGUSR1 {
|
} else if p1 == syscall.SIGUSR1 {
|
||||||
log.Infof("print MessageQueue stats(): %d", z.Stats())
|
log.Printf("print MessageQueue stats(): %d", z.Stats())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -13,11 +13,11 @@ func (z *messageQueue) init() {
|
||||||
go func() {
|
go func() {
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT)
|
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT)
|
||||||
log.Infof("%s Listening SIGTERM/SIGINT...", mqLogPrefix)
|
log.Printf("%sListening SIGTERM/SIGINT...", mqLogPrefix)
|
||||||
for p1 := range c {
|
for p1 := range c {
|
||||||
log.Printf("Received signal: %s", p1)
|
log.Printf("Received signal: %s", p1)
|
||||||
if p1 == syscall.SIGTERM || p1 == syscall.SIGINT {
|
if p1 == syscall.SIGTERM || p1 == syscall.SIGINT {
|
||||||
log.Infof("%s graceful shutting down ... %s", mqLogPrefix, p1)
|
log.Printf("graceful shutting down ... %s", p1)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,9 @@ type streamFunction struct {
|
||||||
// Deprecated: use hpds.WithObserveDataTags instead
|
// Deprecated: use hpds.WithObserveDataTags instead
|
||||||
func (s *streamFunction) SetObserveDataTags(tag ...frame.Tag) {
|
func (s *streamFunction) SetObserveDataTags(tag ...frame.Tag) {
|
||||||
s.client.SetObserveDataTags(tag...)
|
s.client.SetObserveDataTags(tag...)
|
||||||
|
//co := network.WithObserveDataTags(tag...)
|
||||||
|
//s.client.
|
||||||
|
//s.client.SetObserveDataTags(tag...)
|
||||||
s.client.Logger().Debugf("%sSetObserveDataTag(%v)", streamFunctionLogPrefix, s.observeDataTags)
|
s.client.Logger().Debugf("%sSetObserveDataTag(%v)", streamFunctionLogPrefix, s.observeDataTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +86,7 @@ func (s *streamFunction) Connect() error {
|
||||||
s.client.Logger().Debugf("%s Connect()", streamFunctionLogPrefix)
|
s.client.Logger().Debugf("%s Connect()", streamFunctionLogPrefix)
|
||||||
// notify underlying network operations, when data with tag we observed arrived, invoke the func
|
// notify underlying network operations, when data with tag we observed arrived, invoke the func
|
||||||
s.client.SetDataFrameObserver(func(data *frame.DataFrame) {
|
s.client.SetDataFrameObserver(func(data *frame.DataFrame) {
|
||||||
s.client.Logger().Debugf("%s receive DataFrame, tag=%# x, carriage length=%d", streamFunctionLogPrefix, data.Tag(), len(data.GetCarriage()))
|
s.client.Logger().Debugf("%sreceive DataFrame, tag=%# x, carriage=%# x", streamFunctionLogPrefix, data.Tag(), data.GetCarriage())
|
||||||
s.onDataFrame(data.GetCarriage(), data.GetMetaFrame())
|
s.onDataFrame(data.GetCarriage(), data.GetMetaFrame())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -144,13 +147,13 @@ func (s *streamFunction) onDataFrame(data []byte, metaFrame *frame.MetaFrame) {
|
||||||
|
|
||||||
if s.fn != nil {
|
if s.fn != nil {
|
||||||
go func() {
|
go func() {
|
||||||
s.client.Logger().Debugf("%s execute-start fn: data[%d]", streamFunctionLogPrefix, len(data)) //, frame.Shortly(data)
|
s.client.Logger().Debugf("%sexecute-start fn: data[%d]=%# x", streamFunctionLogPrefix, len(data), frame.Shortly(data))
|
||||||
// invoke serverless
|
// invoke serverless
|
||||||
tag, resp := s.fn(data)
|
tag, resp := s.fn(data)
|
||||||
s.client.Logger().Debugf("%s execute-done fn: tag=%#x, resp[%d]", streamFunctionLogPrefix, tag, len(resp))
|
s.client.Logger().Debugf("%sexecute-done fn: tag=%#x, resp[%d]=%# x", streamFunctionLogPrefix, tag, len(resp), frame.Shortly(resp))
|
||||||
// if resp is not nil, means the user's function has returned something, we should send it to the mq
|
// if resp is not nil, means the user's function has returned something, we should send it to the mq
|
||||||
if len(resp) != 0 {
|
if len(resp) != 0 {
|
||||||
s.client.Logger().Debugf("%s start WriteFrame(): tag=%#x, data[%d]", streamFunctionLogPrefix, tag, len(resp))
|
s.client.Logger().Debugf("%sstart WriteFrame(): tag=%#x, data[%d]=%# x", streamFunctionLogPrefix, tag, len(resp), frame.Shortly(resp))
|
||||||
// build a DataFrame
|
// build a DataFrame
|
||||||
// TODO: seems we should implement a DeepCopy() of MetaFrame in the future
|
// TODO: seems we should implement a DeepCopy() of MetaFrame in the future
|
||||||
frm := frame.NewDataFrame()
|
frm := frame.NewDataFrame()
|
||||||
|
@ -163,7 +166,7 @@ func (s *streamFunction) onDataFrame(data []byte, metaFrame *frame.MetaFrame) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else if s.pfn != nil {
|
} else if s.pfn != nil {
|
||||||
s.client.Logger().Debugf("%s pipe fn receive: data[%d]", streamFunctionLogPrefix, len(data))
|
s.client.Logger().Debugf("%spipe fn receive: data[%d]=%# x", streamFunctionLogPrefix, len(data), data)
|
||||||
s.pIn <- data
|
s.pIn <- data
|
||||||
} else {
|
} else {
|
||||||
s.client.Logger().Warnf("%sStreamFunction is nil", streamFunctionLogPrefix)
|
s.client.Logger().Warnf("%sStreamFunction is nil", streamFunctionLogPrefix)
|
||||||
|
|
Loading…
Reference in New Issue