指定slave与master连接中断时的动作。默认为yes,表明slave会继续应答来自client的请求,但这些数据可能已经过期(因为连接中断导致无法从master同步)。若配置为no,则slave除正常应答“INFO”和“SLAVEOF”命令外,其余来自客户端的请求命令均会得到“SYNC with master in progress“的应答,直到该slave与master连接重建成功或该slave被提升为master。
// Package pipefilter is to define the interfaces and the structures for pipe-filter style implementation package pipefilter
// Request is the input of the filter type Request interface{}
// Response is the output of the filter type Response interface{}
// Filter interface is the definition of the data processing components // Pipe-Filter structure type Filter interface { Process(data Request) (Response, error) }
funcTestStringSplit(t *testing.T) { sf := NewSplitFilter(",") resp, err := sf.Process("1,2,3") if err != nil { t.Fatal(err) } parts, ok := resp.([]string) if !ok { t.Fatalf("Repsonse type is %T, but the expected type is string", parts) } if !reflect.DeepEqual(parts, []string{"1", "2", "3"}) { t.Errorf("Expected value is {\"1\",\"2\",\"3\"}, but actual is %v", parts) } }
funcTestWrongInput(t *testing.T) { sf := NewSplitFilter(",") _, err := sf.Process(123) if err == nil { t.Fatal("An error is expected.") } }
type Agent struct { collectors map[string]Collector evtBuf chan Event cancel context.CancelFunc ctx context.Context state int }
func(agt *Agent)EventProcessGroutine() { var evtSeg [10]Event for { for i := 0; i < 10; i++ { select { case evtSeg[i] = <-agt.evtBuf: case <-agt.ctx.Done(): return } } fmt.Println(evtSeg) }