Compare commits
	
		
			5 Commits
		
	
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								 | 
						d4bc0298e1 | |
| 
							
							
								 | 
						e9e2d833c4 | |
| 
							
							
								 | 
						47b7490878 | |
| 
							
							
								 | 
						9403c4d01e | |
| 
							
							
								 | 
						033e5f845d | 
							
								
								
									
										4
									
								
								ap.go
								
								
								
								
							
							
						
						
									
										4
									
								
								ap.go
								
								
								
								
							| 
						 | 
				
			
			@ -99,8 +99,8 @@ func (s *accessPoint) WriteWithTag(tag frame.Tag, data []byte) error {
 | 
			
		|||
	f := frame.NewDataFrame()
 | 
			
		||||
	f.SetCarriage(tag, data)
 | 
			
		||||
	f.SetSourceId(s.client.ClientId())
 | 
			
		||||
	log.Debugf("%s WriteWithTag: tid=%s, source_id=%s, data[%d]=%# x",
 | 
			
		||||
		apLogPrefix, f.TransactionId(), f.SourceId(), len(data), frame.Shortly(data))
 | 
			
		||||
	log.Debugf("%s WriteWithTag: tid=%s, source_id=%s, data[%d]",
 | 
			
		||||
		apLogPrefix, f.TransactionId(), f.SourceId(), len(data))
 | 
			
		||||
	return s.client.WriteFrame(f)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ package main
 | 
			
		|||
import (
 | 
			
		||||
	"crypto/sha1"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"git.hpds.cc/Component/network/frame"
 | 
			
		||||
	"git.hpds.cc/Component/network/log"
 | 
			
		||||
	"git.hpds.cc/pavement/hpds_node"
 | 
			
		||||
	"os"
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +26,7 @@ func main() {
 | 
			
		|||
	)
 | 
			
		||||
	defer sf.Close()
 | 
			
		||||
 | 
			
		||||
	sf.SetHandler(Handler)
 | 
			
		||||
	_ = sf.SetHandler(Handler)
 | 
			
		||||
 | 
			
		||||
	err := sf.Connect()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +38,7 @@ func main() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// Handler process the data in the stream
 | 
			
		||||
func Handler(img []byte) (byte, []byte) {
 | 
			
		||||
func Handler(img []byte) (frame.Tag, []byte) {
 | 
			
		||||
	// Initialize WasmEdge's VM
 | 
			
		||||
	//vmConf, vm := initVM()
 | 
			
		||||
	//bg := bindgen.Instantiate(vm)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										56
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										56
									
								
								go.mod
								
								
								
								
							| 
						 | 
				
			
			@ -1,41 +1,51 @@
 | 
			
		|||
module git.hpds.cc/pavement/hpds_node
 | 
			
		||||
 | 
			
		||||
go 1.19
 | 
			
		||||
go 1.23
 | 
			
		||||
 | 
			
		||||
toolchain go1.23.4
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	git.hpds.cc/Component/network v0.0.0-20230405125523-abb93c020ff5
 | 
			
		||||
	git.hpds.cc/Component/network v0.0.0-20241213034701-8d0c63079944
 | 
			
		||||
	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/u2takey/ffmpeg-go v0.4.1
 | 
			
		||||
	github.com/quic-go/quic-go v0.48.2
 | 
			
		||||
	github.com/stretchr/testify v1.10.0
 | 
			
		||||
	github.com/u2takey/ffmpeg-go v0.5.0
 | 
			
		||||
	gopkg.in/yaml.v3 v3.0.1
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	git.hpds.cc/Component/mq_coder v0.0.0-20221010064749-174ae7ae3340 // indirect
 | 
			
		||||
	github.com/aws/aws-sdk-go v1.38.20 // indirect
 | 
			
		||||
	git.hpds.cc/Component/mq_coder v0.0.0-20241213034522-3a3512d94b34 // indirect
 | 
			
		||||
	github.com/aws/aws-sdk-go v1.55.5 // indirect
 | 
			
		||||
	github.com/davecgh/go-spew v1.1.1 // indirect
 | 
			
		||||
	github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
 | 
			
		||||
	github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
 | 
			
		||||
	github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
 | 
			
		||||
	github.com/golang/mock v1.6.0 // indirect
 | 
			
		||||
	github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
 | 
			
		||||
	github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
 | 
			
		||||
	github.com/jmespath/go-jmespath v0.4.0 // indirect
 | 
			
		||||
	github.com/kr/text v0.2.0 // indirect
 | 
			
		||||
	github.com/matoous/go-nanoid/v2 v2.0.0 // indirect
 | 
			
		||||
	github.com/onsi/ginkgo/v2 v2.2.0 // indirect
 | 
			
		||||
	github.com/matoous/go-nanoid/v2 v2.1.0 // indirect
 | 
			
		||||
	github.com/onsi/ginkgo/v2 v2.22.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-20 v0.1.1 // indirect
 | 
			
		||||
	github.com/quic-go/qtls-go1-20 v0.3.3 // indirect
 | 
			
		||||
	github.com/rogpeppe/go-internal v1.9.0 // indirect
 | 
			
		||||
	github.com/stretchr/objx v0.5.2 // indirect
 | 
			
		||||
	github.com/u2takey/go-utils v0.3.1 // indirect
 | 
			
		||||
	go.uber.org/atomic v1.7.0 // indirect
 | 
			
		||||
	go.uber.org/multierr v1.6.0 // indirect
 | 
			
		||||
	go.uber.org/zap v1.23.0 // indirect
 | 
			
		||||
	golang.org/x/crypto v0.4.0 // indirect
 | 
			
		||||
	golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
 | 
			
		||||
	golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
 | 
			
		||||
	golang.org/x/mod v0.6.0 // indirect
 | 
			
		||||
	golang.org/x/net v0.4.0 // indirect
 | 
			
		||||
	golang.org/x/sys v0.3.0 // indirect
 | 
			
		||||
	golang.org/x/tools v0.2.0 // indirect
 | 
			
		||||
	gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
 | 
			
		||||
	go.uber.org/atomic v1.11.0 // indirect
 | 
			
		||||
	go.uber.org/mock v0.5.0 // indirect
 | 
			
		||||
	go.uber.org/multierr v1.11.0 // indirect
 | 
			
		||||
	go.uber.org/zap v1.27.0 // indirect
 | 
			
		||||
	golang.org/x/crypto v0.31.0 // indirect
 | 
			
		||||
	golang.org/x/exp v0.0.0-20241210194714-1829a127f884 // indirect
 | 
			
		||||
	golang.org/x/image v0.23.0 // indirect
 | 
			
		||||
	golang.org/x/mod v0.22.0 // indirect
 | 
			
		||||
	golang.org/x/net v0.32.0 // indirect
 | 
			
		||||
	golang.org/x/sync v0.10.0 // indirect
 | 
			
		||||
	golang.org/x/sys v0.28.0 // indirect
 | 
			
		||||
	golang.org/x/tools v0.28.0 // indirect
 | 
			
		||||
	gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
//replace (
 | 
			
		||||
//	git.hpds.cc/Component/network => ../network
 | 
			
		||||
//)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -83,7 +83,7 @@ func (s *streamFunction) Connect() error {
 | 
			
		|||
	s.client.Logger().Debugf("%s Connect()", streamFunctionLogPrefix)
 | 
			
		||||
	// notify underlying network operations, when data with tag we observed arrived, invoke the func
 | 
			
		||||
	s.client.SetDataFrameObserver(func(data *frame.DataFrame) {
 | 
			
		||||
		s.client.Logger().Debugf("%s receive DataFrame, tag=%# x, carriage=%# x", streamFunctionLogPrefix, data.Tag(), data.GetCarriage())
 | 
			
		||||
		s.client.Logger().Debugf("%s receive DataFrame, tag=%# x, carriage length=%d", streamFunctionLogPrefix, data.Tag(), len(data.GetCarriage()))
 | 
			
		||||
		s.onDataFrame(data.GetCarriage(), data.GetMetaFrame())
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -144,13 +144,13 @@ func (s *streamFunction) onDataFrame(data []byte, metaFrame *frame.MetaFrame) {
 | 
			
		|||
 | 
			
		||||
	if s.fn != nil {
 | 
			
		||||
		go func() {
 | 
			
		||||
			s.client.Logger().Debugf("%s execute-start fn: data[%d]=%# x", streamFunctionLogPrefix, len(data), frame.Shortly(data))
 | 
			
		||||
			s.client.Logger().Debugf("%s execute-start fn: data[%d]", streamFunctionLogPrefix, len(data)) //, frame.Shortly(data)
 | 
			
		||||
			// invoke serverless
 | 
			
		||||
			tag, resp := s.fn(data)
 | 
			
		||||
			s.client.Logger().Debugf("%s execute-done fn: tag=%#x, resp[%d]=%# x", streamFunctionLogPrefix, tag, len(resp), frame.Shortly(resp))
 | 
			
		||||
			s.client.Logger().Debugf("%s execute-done fn: tag=%#x, resp[%d]", streamFunctionLogPrefix, tag, len(resp))
 | 
			
		||||
			// if resp is not nil, means the user's function has returned something, we should send it to the mq
 | 
			
		||||
			if len(resp) != 0 {
 | 
			
		||||
				s.client.Logger().Debugf("%s start WriteFrame(): tag=%#x, data[%d]=%# x", streamFunctionLogPrefix, tag, len(resp), frame.Shortly(resp))
 | 
			
		||||
				s.client.Logger().Debugf("%s start WriteFrame(): tag=%#x, data[%d]", streamFunctionLogPrefix, tag, len(resp))
 | 
			
		||||
				// build a DataFrame
 | 
			
		||||
				// TODO: seems we should implement a DeepCopy() of MetaFrame in the future
 | 
			
		||||
				frm := frame.NewDataFrame()
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +163,7 @@ func (s *streamFunction) onDataFrame(data []byte, metaFrame *frame.MetaFrame) {
 | 
			
		|||
			}
 | 
			
		||||
		}()
 | 
			
		||||
	} else if s.pfn != nil {
 | 
			
		||||
		s.client.Logger().Debugf("%s pipe fn receive: data[%d]=%# x", streamFunctionLogPrefix, len(data), data)
 | 
			
		||||
		s.client.Logger().Debugf("%s pipe fn receive: data[%d]", streamFunctionLogPrefix, len(data))
 | 
			
		||||
		s.pIn <- data
 | 
			
		||||
	} else {
 | 
			
		||||
		s.client.Logger().Warnf("%s StreamFunction is nil", streamFunctionLogPrefix)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue