Questions about Asynchronous Communication Feature in GoTask
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia con gli entry point gotask.Register e gotask.Run mostrati nell’esempio, quindi esamina il package alla ricerca di API esistenti per i risultati delle attività o la comunicazione. Determina se gli aggiornamenti parziali sono attualmente supportati e documenta l’utilizzo pertinente, oppure definisci l’ambito di una nuova funzionalità di comunicazione asincrona. Nell’issue non sono indicati file o test specifici.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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!
- Lingua principale
- PHP
- Stelle
- 255
- Fork
- 29
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hyperf/gotask
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
-
这个项目还维护吗Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
-
gotask是不支持协程风格吗?Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Tutte le issue di hyperf/gotask
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
benjaminkott/bootstrap_package#1675 ·
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno