Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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" | |
zerolog "github.com/rs/zerolog/log" | |
"github.com/sirupsen/logrus" | |
"go.uber.org/zap" | |
"log" | |
"net/http" | |
) |
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 "github.com/tidwall/gjson" | |
const json = `{"name":{"first":"Janet","last":"Prichard"},"age":47}` | |
type User struct{ | |
FirstName string `gjson:"name.first"` | |
LastName string `gjson:"name.last"` | |
Age string `gjson:"age"` |
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 ( | |
"log" | |
"net/http" | |
) | |
func main() { | |
// Simple static webserver: | |
log.Fatal(http.ListenAndServe(":8080", http.FileServer(http.Dir("/usr/share/doc")))) |
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
errs := make(chan error, 2) | |
server := &http.Server{Addr: ":8080", Handler: handler} | |
go func() { | |
errs <- server.ListenAndServe() | |
} | |
go func() { | |
// Setting up signal capturing | |
c := make(chan os.Signal) |
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" | |
lucio "github.com/arriqaaq/server" | |
"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
func main() { | |
client := boomerang.NewHttpClient(clientCnf) | |
mux := http.NewServeMux() | |
mux.HandleFunc("/ping", func(w http.ResponseWriter, req *http.Request) { | |
request, _ := http.NewRequest("GET", URL_SERVICE_B, strings.NewReader("gopher")) | |
resp, httpErr := client.Do(request) | |
if httpErr != nil { | |
fmt.Println("ping failed ", httpErr) | |
w.Write([]byte("fail")) | |
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 main() { | |
client := redis.NewClient(&redis.Options{Addr:"localhost:6379",Password: "", DB:0, // use default DB}) | |
pong, err := client.Ping().Result() | |
if err == nil { | |
log.Fatalln(pong, err) | |
} | |
client.Set("isco", "alarcon", 0).Err() | |
promCtx := boomerang.NewPrometheusMetrics("service_b", "info") | |
mux := http.NewServeMux() | |
mux.HandleFunc("/pong", func(w http.ResponseWriter, req *http.Request) { |
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
// fingerEntry represents a single finger table entry | |
type fingerEntry struct { | |
Id []byte // ID hash of (n + 2^i) mod (2^m) | |
Node *internal.Node | |
} | |
func newFingerTable(node *internal.Node, m int) fingerTable { | |
ft := make([]*fingerEntry, m) | |
for i := range ft { | |
ft[i] = newFingerEntry(fingerID(node.Id, i, m), node) |
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
type Node struct { | |
*internal.Node | |
predecessor *internal.Node | |
successor *internal.Node | |
fingerTable fingerTable | |
storage Storage | |
transport Transport | |
} |
OlderNewer