Skip to content

Commit

Permalink
chore: tcp example (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusprubio authored Apr 22, 2024
1 parent 9a889e2 commit 1356e6f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/tcp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"context"
"fmt"
"log/slog"
"os"
"time"

"github.com/jesusprubio/up/pkg"
)

func main() {
logger := slog.New(slog.NewTextHandler(os.Stderr, nil))
probe := pkg.Probe{
Protocols: []*pkg.Protocol{pkg.Protocols[1]},
Count: 3,
Timeout: 2 * time.Second,
Logger: logger,
ReportCh: make(chan *pkg.Report),
}
go func() {
for report := range probe.ReportCh {
fmt.Println(report)
}
}()
err := probe.Run(context.Background())
if err != nil {
fmt.Printf("Error: %s\n", err)
}
}

0 comments on commit 1356e6f

Please sign in to comment.