Added devp-deploy to rbd-exporter
This commit is contained in:
parent
ec2b96105f
commit
389dcbc366
3
book_with_bridge/channels/go.mod
Normal file
3
book_with_bridge/channels/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
module main
|
||||||
|
|
||||||
|
go 1.24.5
|
||||||
3
book_with_bridge/channels/launch!/go.mod
Normal file
3
book_with_bridge/channels/launch!/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
module main
|
||||||
|
|
||||||
|
go 1.24.5
|
||||||
36
book_with_bridge/channels/launch!/main.go
Normal file
36
book_with_bridge/channels/launch!/main.go
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func launch() {
|
||||||
|
fmt.Println("To abort launch press Enter")
|
||||||
|
for i:=10;i >=0; i-- {
|
||||||
|
fmt.Printf("%d...\n",i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
abort := make(chan struct{})
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
os.Stdin.Read(make([]byte,1))
|
||||||
|
abort <- struct{}{}
|
||||||
|
}()
|
||||||
|
|
||||||
|
tick := time.Tick(1*time.Second)
|
||||||
|
|
||||||
|
for i:=10; i>=0; i-- {
|
||||||
|
fmt.Printf("%d...\n",i)
|
||||||
|
select {
|
||||||
|
case <-tick:
|
||||||
|
case <- abort:
|
||||||
|
fmt.Println("Launch cancelled")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
book_with_bridge/channels/main.go
Normal file
26
book_with_bridge/channels/main.go
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func kek(i int) {
|
||||||
|
res_string := ""
|
||||||
|
for range i {
|
||||||
|
res_string += " "
|
||||||
|
}
|
||||||
|
fmt.Println(res_string,i)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
done := make(chan int)
|
||||||
|
|
||||||
|
for i:=range 10 {
|
||||||
|
go func() {
|
||||||
|
kek(i)
|
||||||
|
done <- 1
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
for range 10 {
|
||||||
|
<- done
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
|
@ -9,7 +10,7 @@ import (
|
||||||
|
|
||||||
func mustCopy(dst io.Writer,src io.Reader) {
|
func mustCopy(dst io.Writer,src io.Reader) {
|
||||||
if _,err := io.Copy(dst,src); err != nil {
|
if _,err := io.Copy(dst,src); err != nil {
|
||||||
log.Fatalf("Error in mustCopy",err)
|
log.Fatalf("Error in mustCopy %s",err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -20,7 +21,14 @@ func main() {
|
||||||
log.Fatalf("Error in Dial %s",err)
|
log.Fatalf("Error in Dial %s",err)
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
done := make(chan struct{})
|
||||||
|
|
||||||
go mustCopy(os.Stdout,conn)
|
go func() {
|
||||||
mustCopy(conn,os.Stdin)
|
io.Copy(os.Stdin,conn)
|
||||||
|
fmt.Println("done")
|
||||||
|
done <- struct{}{}
|
||||||
|
}()
|
||||||
|
io.Copy(conn,os.Stdout)
|
||||||
|
conn.Close()
|
||||||
|
<-done
|
||||||
}
|
}
|
||||||
|
|
@ -10,23 +10,46 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func echo(c net.Conn, shout string, t time.Duration) {
|
func echo(c net.Conn, shout string, t time.Duration) {
|
||||||
|
for _ = range 3 {
|
||||||
fmt.Fprintln(c, "\t", strings.ToUpper(shout))
|
fmt.Fprintln(c, "\t", strings.ToUpper(shout))
|
||||||
time.Sleep(t)
|
time.Sleep(t)
|
||||||
fmt.Fprintln(c, "\t", shout)
|
}
|
||||||
time.Sleep(t)
|
|
||||||
fmt.Fprintln(c, "\t", strings.ToLower(shout))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleConn(conn net.Conn) {
|
func handleConn(conn net.Conn) {
|
||||||
|
|
||||||
|
count := 1
|
||||||
defer fmt.Println("CLosed Connection")
|
defer fmt.Println("CLosed Connection")
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
fmt.Println("Accepted connection")
|
fmt.Println("Accepted connection")
|
||||||
|
|
||||||
|
ticker := time.NewTicker(2*time.Second)
|
||||||
|
|
||||||
input := bufio.NewScanner(conn)
|
input := bufio.NewScanner(conn)
|
||||||
for input.Scan() {
|
select {
|
||||||
go echo(conn, input.Text(), 1*time.Second)
|
case <- ticker.C:
|
||||||
|
fmt.Println("TIMEOUT")
|
||||||
|
default:
|
||||||
|
fmt.Println("DEFAULT")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for input.Scan() {
|
||||||
|
fmt.Println("TICK")
|
||||||
|
switch input.Text() {
|
||||||
|
case "info":
|
||||||
|
fmt.Printf("INFO %d",count)
|
||||||
|
default:
|
||||||
|
count++
|
||||||
|
go func() {
|
||||||
|
defer func (){
|
||||||
|
count--
|
||||||
|
}()
|
||||||
|
echo(conn, input.Text(), 1*time.Second)
|
||||||
|
}()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user