Upload files to "/"

This commit is contained in:
5803024006 2025-10-01 06:46:10 -04:00
parent c5b737287e
commit 6ad17dc96e
3 changed files with 45 additions and 0 deletions

18
context_handler.go Normal file
View File

@ -0,0 +1,18 @@
package main
import (
"context"
"fmt"
"time"
)
func FetchRiwayatKursus(ctx context.Context) error {
select {
case <-time.After(2 * time.Second): // simulasi lama fetch
userID := ctx.Value("UserID").(string)
fmt.Println("Riwayat kursus untuk user:", userID)
return nil
case <-ctx.Done():
return ctx.Err()
}
}

13
poll_worker.go Normal file
View File

@ -0,0 +1,13 @@
package main
import (
"fmt"
"time"
)
func PollJobWorker(id int, jobs <-chan int) {
for job := range jobs {
fmt.Printf("Worker %d: memproses poll job %d\n", id, job)
time.Sleep(50 * time.Millisecond)
}
}

14
worker.go Normal file
View File

@ -0,0 +1,14 @@
package main
import (
"fmt"
"sync"
"time"
)
func ProsesSertifikasi(userID int, wg *sync.WaitGroup) {
defer wg.Done()
fmt.Printf("User %d: mulai proses sertifikasi...\n", userID)
time.Sleep(200 * time.Millisecond) // simulasi proses
fmt.Printf("User %d: sertifikasi selesai!\n", userID)
}