This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package client_test | |
| import ( | |
| "bytes" | |
| "encoding/json" | |
| "strings" | |
| "testing" | |
| "github.com/wallix/gopeps/pepssdk/go/client" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package client | |
| import ( | |
| "encoding/base64" | |
| "reflect" | |
| ) | |
| func DecodeBase64Payload(i interface{}) { | |
| val, ok := getStructPtr(i) | |
| if !ok { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "os" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| func main() { | |
| //params := []string{"1", "2", "3"} | |
| fmt.Println(and(and(stringNode("1"), stringNode("2")), or(stringNode("3")))) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "context" | |
| "flag" | |
| "fmt" | |
| "log" | |
| "sort" | |
| "time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "sync" | |
| "time" | |
| ) | |
| func main() { | |
| cmds := []*cmd{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func printOk(s string, a ...interface{}) { | |
| fmt.Printf("\033[32m[OK]\033[m %s\n", fmt.Sprintf(s, a...)) | |
| } | |
| func printKo(s string, a ...interface{}) { | |
| fmt.Fprintf(os.Stderr, "\033[31m[KO]\033[m %s\n", fmt.Sprintf(s, a...)) | |
| } | |
| func printInfo(s string, a ...interface{}) { | |
| fmt.Printf("[+] %s\n", fmt.Sprintf(s, a...)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (a *replayAggregator) Run() { | |
| var timer = time.NewTimer(a.flushFrequency) | |
| var elapsed <-chan time.Time | |
| var out chan []*sarama.ConsumerMessage | |
| for { | |
| select { | |
| case msg := <-a.in: | |
| if !a.slicer.add(msg) { | |
| a.out <- a.slicer.flush() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ... | |
| bodyBuf := getBuf() | |
| _, err := bodyBuf.ReadFrom(body) | |
| if err != nil { | |
| putBuf(bodyBuf) | |
| jsonError(w, http.StatusInternalServerError, "problem reading request body") | |
| return | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (c *Collector) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
| limitReader := http.MaxBytesReader(w, r.Body, c.MaxPayloadSize) | |
| payload, err := ioutil.ReadAll(limitReader) | |
| if err != nil { | |
| w.WriteHeader(http.StatusInternalServerError) | |
| if IsIgnorableError(err) { | |
| return | |
| } | |
| log.Printf("read body from %s: %s\n%s", err, RemoteAddr(r), payload) | |
| return |