Questions about Asynchronous Communication Feature in GoTask
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Beginne mit den im Beispiel gezeigten Einstiegspunkten gotask.Register und gotask.Run und untersuche anschließend das Paket auf vorhandene APIs für Aufgabenergebnisse oder Kommunikation. Ermittle, ob derzeit partielle Aktualisierungen unterstützt werden, und dokumentiere die relevante Verwendung oder lege den Umfang eines neuen asynchronen Kommunikationsfeatures fest. Im Issue werden keine bestimmten Dateien oder Tests genannt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
Problem Description:
I'm exploring the usage of the gotask package in my project and I'm encountering a scenario where I need to execute heavy processes using Go tasks. However, I'm looking for a feature that allows asynchronous communication between the code triggering the Go tasks and the tasks themselves. This feature would enable me to receive partial results or updates from the process as it progresses, similar to a "yield" mechanism in asynchronous languages.
Question
- Does the gotask package already include the functionality for asynchronous communication?
- If yes, how can I use this functionality to receive updates or partial results from Go tasks while they are being processed?
- If the functionality doesn't exist, do you have any suggestions or tips on how I can implement this type of asynchronous communication in conjunction with the gotask package?
Examples
If possible, I would appreciate seeing examples of how this functionality can be implemented, whether by using existing features within the gotask package or through suggestions on extending the code to achieve this goal. Below is an example of what I have in mind:
package main
import (
"log"
"time"
"github.com/hyperf/gotask/v2/pkg/gotask"
)
// App sample
type App struct{}
// ProcessBatch executes batch processing and sends asynchronous updates.
func (a *App) ProcessBatch(input interface{}, r *string) error {
for i := 1; i <= 10; i++ {
// Simulating heavy processing
time.Sleep(1 * time.Second)
// Sending asynchronous update
gotask.AsyncUpdate(fmt.Sprintf("Processed %d items", i))
}
*r = "Processing completed"
return nil
}
func main() {
if err := gotask.Register(new(App)); err != nil {
log.Fatalln(err)
}
if err := gotask.Run(); err != nil {
log.Fatalln(err)
}
}
Benefits
Implementing this asynchronous communication feature between Go tasks and the triggering code would open up new possibilities for utilizing the gotask package. Furthermore, this feature would enhance the utility of the library for heavy processing scenarios.
Thank you in advance for your attention and assistance!
- Vorherrschende Sprache
- PHP
- Sterne
- 255
- Forks
- 29
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus hyperf/gotask
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 20/100
-
这个项目还维护吗Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
-
gotask是不支持协程风格吗?Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
mailcow/mailcow-dockerized#7652 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 91/100
benjaminkott/bootstrap_package#1675 ·