watcher

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 2 Imported by: 1

README

watcher any for Golang

Go Tests

Installation

go get github.com/goxtools/watcher@v0.0.1

Quickstart

for consumer [old version]
- ch := make(chan int, c.GetConsumerNumber())
- for {
-    ch <- 1
-    go func(channel chan int, c mq.Consumer) {
-        defer gorecover.GoRecover(context.Background(), c.GetConsumerName()+"job异常")
-        ctx := new(Context)
-        if err := c.Consumer(ctx); err != nil {
-            <-channel
-            return
-        }
-        <-channel
-    }(ch, c)
-}
for consumer [watcher]
for i := 0; i < c.GetConsumerNumber(); i++{
    go watch.Watcher(func() {
        ctx := new(Context)
        c.Consumer(ctx)
    })
}

Test Case


func TestSen(t *testing.T) {

	ti := time.NewTicker(time.Second * 1)
	go Watcher(func(args ...interface{}) {
		for {
			select {
			case <-ti.C:
				fmt.Println(time.Now().Second())
				if time.Now().Second()%5 == 0 {
					panic("123312")
				}
			default:
				time.Sleep(time.Millisecond * 50)
			}
		}
	})

	for {
		select {

		}
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Watcher

func Watcher(f func(args ...interface{}))

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL