Skip to content

Conversation

@jeff-cohere
Copy link
Collaborator

@jeff-cohere jeff-cohere commented Oct 14, 2025

The tasks package is kind of a mess--it has a single goroutine that updates the states of all the transfers in a very cross-cutting way, and then it has another goroutine that provides a "heartbeat" to poke it for the next update.

The transfers package that replaces it breaks up the work of file transfers into distinct goroutines with crisp areas of responsibility:

  • The dispatcher accepts transfer-related requests from a "clients" (a properly-routed request from the web service (the
    prototype code in services/) and coordinates with the other goroutines
  • The store maintains the state of a transfer and makes metadata available to other goroutines
  • The stager handles file staging operations as needed
  • The mover handles the actual transfer of the payload
  • The manifestor generates the metadata manifest for a completed transfer, and transfers it into place with the rest of the payload.
  • A simple messaging service now publishes transfer status message to subscribers. Log messages and tests use this machinery, and we can easily use it to publish to external message queues.
  • Completed transfers (successful or not) are now recorded to the transfer journal.

I've used private package global variables for simple namespacing.

Closes #159

@github-actions
Copy link
Contributor

github-actions bot commented Oct 14, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://kbase.github.io/dts/pr-preview/pr-162/

Built to branch gh-pages at 2025-11-06 22:57 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@jeff-cohere
Copy link
Collaborator Author

We're almost there. I just need to do a bit more testing of the new orchestration logic within the service, and then propagate the config data structure.

@jeff-cohere jeff-cohere force-pushed the tasks-refactor branch 3 times, most recently from 1614b3e to 7c16405 Compare October 28, 2025 23:43
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 17.94872% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.54%. Comparing base (43fed6f) to head (a86719d).

Files with missing lines Patch % Lines
dtstest/dtstest.go 0.00% 24 Missing ⚠️
databases/databases.go 0.00% 5 Missing ⚠️
services/prototype.go 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #162      +/-   ##
==========================================
+ Coverage   64.06%   66.54%   +2.48%     
==========================================
  Files          24       20       -4     
  Lines        2585     1949     -636     
==========================================
- Hits         1656     1297     -359     
+ Misses        754      542     -212     
+ Partials      175      110      -65     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeff-cohere jeff-cohere marked this pull request as ready for review October 29, 2025 16:38
@jeff-cohere
Copy link
Collaborator Author

I want to test this "in production" over the weekend before merging it.

Copy link
Collaborator

@mattldawson mattldawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really nice! I just have a couple minor questions/comments, mostly about how goroutines interact.

What wasn't obvious to me at first is that successful staging triggers a move directly, and moves trigger manifests to be generated, and that all three directly set the status for the transfer. It all makes sense now, but I wonder if there is somewhere to put this info so it's easy for a newbie like me to get a picture of the overall workflow?

@mattldawson
Copy link
Collaborator

One thing I was curious about is why you set the channel buffers to 32? could there ever be more than one element in each channel?

@jeff-cohere
Copy link
Collaborator Author

jeff-cohere commented Oct 29, 2025

One thing I was curious about is why you set the channel buffers to 32? could there ever be more than one element in each channel?

Good point. We should probably relate this to the number of allowed HTTP connections via a parameter. And I should go over the code and change the channel buffers to reflect the actual expected queue sizes.

@jeff-cohere
Copy link
Collaborator Author

Okay, I think this is ready to go--I've tested it in Spin with dtspy and with Ken Chu's IMG -> KBase push service.

Copy link
Collaborator

@mattldawson mattldawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!


type dispatcherChannels struct {
RequestTransfer chan Specification // used by client to create a new transfer
ReturnTransferId chan uuid.UUID // returns task ID to client
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ReturnTransferId chan uuid.UUID // returns task ID to client
ReturnTransferId chan uuid.UUID // returns transfer ID to client

d.Channels.CancelTransfer <- transferId
err := <-d.Channels.Error
if err != nil {
slog.Error(fmt.Sprintf("Transfer %s: %s", transferId.String(), err.Error()))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big deal, but if we log cancel errors, should we also log errors for other dispatcher functions?

Comment on lines +46 to +50
/*
dispatcherTests := DispatcherTests{Test: t}
print("dispatcher start/stop\n")
dispatcherTests.TestStartAndStop()
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor and simplify transfer task orchestration logic.

3 participants