Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment with sending chunks of binary payload #4512

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
nicksanford committed Oct 17, 2024
commit ce4600f7b35e21f03c584a54ff0d92d9e3fc411b
6 changes: 3 additions & 3 deletions data/capture_buffer_test.go
Original file line number Diff line number Diff line change
@@ -620,7 +620,7 @@ func TestCaptureBufferReader(t *testing.T) {

// Path() is the same as the first paramenter passed to NewCaptureBuffer
test.That(t, b.Path(), test.ShouldResemble, tmpDir)
test.That(t, b.MetaData, test.ShouldResemble, readImageCaptureMetadata)
test.That(t, b.metaData, test.ShouldResemble, readImageCaptureMetadata)

now := time.Now()
timeRequested := timestamppb.New(now.UTC())
@@ -689,7 +689,7 @@ func NickTest(t *testing.T) {

// Path() is the same as the first paramenter passed to NewCaptureBuffer
test.That(t, b.Path(), test.ShouldResemble, tmpDir)
test.That(t, b.MetaData, test.ShouldResemble, readImageCaptureMetadata)
test.That(t, b.metaData, test.ShouldResemble, readImageCaptureMetadata)

now := time.Now()
timeRequested := timestamppb.New(now.UTC())
@@ -725,7 +725,7 @@ func NickTest(t *testing.T) {
test.That(t, err, test.ShouldBeError, io.EOF)
}

// nolint
//nolint
func getCaptureFiles(dir string) (dcFiles, progFiles []string) {
_ = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
26 changes: 13 additions & 13 deletions data/capture_file.go
Original file line number Diff line number Diff line change
@@ -194,19 +194,19 @@ func getDataType(methodName string) v1.DataType {

// SensorDataFromCaptureFilePath returns all readings in the file at filePath.
// NOTE: (Nick S) At time of writing this is only used in tests.
//func SensorDataFromCaptureFilePath(filePath string) ([]*v1.SensorData, error) {
// //nolint:gosec
// f, err := os.Open(filePath)
// if err != nil {
// return nil, err
// }
// dcFile, err := NewCaptureFile(f)
// if err != nil {
// return nil, err
// }

// return SensorDataFromCaptureFile(dcFile)
//}
func SensorDataFromCaptureFilePath(filePath string) ([]*v1.SensorData, error) {
//nolint:gosec
f, err := os.Open(filePath)
if err != nil {
return nil, err
}
dcFile, err := NewCaptureFile(f)
if err != nil {
return nil, err
}

return SensorDataFromCaptureFile(dcFile)
}

// SensorDataFromCaptureFile returns all readings in f.
func SensorDataFromCaptureFile(f *CaptureFile) ([]*v1.SensorData, error) {
2 changes: 1 addition & 1 deletion services/datamanager/builtin/builtin_sync_test.go
Original file line number Diff line number Diff line change
@@ -1055,7 +1055,7 @@ func getCapturedData(filePaths []string) (int, []*v1.SensorData, error) {
if err != nil {
return 0, nil, err
}
dcFile, err := data.ReadCaptureFile(osFile)
dcFile, err := data.NewCaptureFile(osFile)
if err != nil {
return 0, nil, err
}
2 changes: 1 addition & 1 deletion services/datamanager/builtin/capture/capture.go
Original file line number Diff line number Diff line change
@@ -269,7 +269,7 @@ func collectorConfigDescription(
}

func targetDir(captureDir string, collectorConfig datamanager.DataCaptureConfig) string {
return data.CaptureFilePathWithReplacedReservedChars(
return data.FilePathWithReplacedReservedChars(
filepath.Join(captureDir, collectorConfig.Name.API.String(),
collectorConfig.Name.ShortName(), collectorConfig.Method))
}
2 changes: 1 addition & 1 deletion services/datamanager/builtin/sync/sync.go
Original file line number Diff line number Diff line change
@@ -367,7 +367,7 @@ func (s *Sync) syncFile(config Config, filePath string) {
}

func (s *Sync) syncDataCaptureFile(f *os.File, captureDir string, logger logging.Logger) {
captureFile, err := data.ReadCaptureFile(f)
captureFile, err := data.NewCaptureFile(f)
// if you can't read the capture file's metadata field, close & move it to the failed directory
if err != nil {
cause := errors.Wrap(err, "ReadCaptureFile failed")