Upload files to "/"
This commit is contained in:
parent
c5b737287e
commit
6ad17dc96e
18
context_handler.go
Normal file
18
context_handler.go
Normal 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
13
poll_worker.go
Normal 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
14
worker.go
Normal 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)
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user