35 lines
678 B
Go
35 lines
678 B
Go
package main
|
|
|
|
import (
|
|
// "fmt"
|
|
"net"
|
|
"os"
|
|
"time"
|
|
// "net"
|
|
"context"
|
|
"log/slog"
|
|
)
|
|
|
|
type Config struct{
|
|
introducer_ip string
|
|
port int
|
|
my_ip *net.IP
|
|
gossip_heartbeat_interval time.Duration
|
|
join_retry_interval time.Duration
|
|
gossip_fanout int
|
|
gossip_failure_timeout time.Duration
|
|
}
|
|
|
|
func main(){
|
|
ctx := context.TODO()
|
|
|
|
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
|
|
|
|
//dial up trick to get my_ip
|
|
conn, _ := net.Dial("udp", "8.8.8.8:80"); defer conn.Close(); my_ip := conn.LocalAddr().(*net.UDPAddr).IP
|
|
|
|
config := Config{"172.22.156.3", 8989, &my_ip, 250 * time.Millisecond, 1 * time.Second, 2, 6 * time.Second}
|
|
|
|
start_membership(ctx, config, logger)
|
|
|
|
} |