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() { | |
| // Create NATS server connection | |
| natsConnection, _ := nats.Connect(nats.DefaultURL) | |
| log.Println("Connected to " + nats.DefaultURL) | |
| msg, err := natsConnection.Request("Discovery.OrderService", nil, 1000*time.Millisecond) | |
| if err == nil && msg != nil { | |
| orderServiceDiscovery := pb.ServiceDiscovery{} | |
| err := proto.Unmarshal(msg.Data, &orderServiceDiscovery) |
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
| // Benchmark testing to measure the performance of marshaling and unmarshaling of ProtoBuf, JSON and XML | |
| package order | |
| import ( | |
| "encoding/json" | |
| "encoding/xml" | |
| "testing" | |
| "time" | |
| "github.com/golang/protobuf/proto" |
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 ( | |
| "io" | |
| "log" | |
| "golang.org/x/net/context" | |
| "google.golang.org/grpc" | |
| pb "github.com/shijuvar/go-recipes/grpc/customer" |
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" | |
| "strings" | |
| "golang.org/x/net/context" | |
| "google.golang.org/grpc" |
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
| // Code generated by protoc-gen-go. | |
| // source: customer.proto | |
| // DO NOT EDIT! | |
| /* | |
| Package customer is a generated protocol buffer package. | |
| It is generated from these files: | |
| customer.proto |
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
| syntax = "proto3"; | |
| package customer; | |
| // The Customer service definition. | |
| service Customer { | |
| // Get all Customers with filter - A server-to-client streaming RPC. | |
| rpc GetCustomers(CustomerFilter) returns (stream CustomerRequest) {} | |
| // Create a new Customer - A simple RPC | |
| rpc CreateCustomer (CustomerRequest) returns (CustomerResponse) {} |
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" | |
| "log" | |
| "net/http" | |
| ) | |
| func indexHandler(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "Welcome to Go Web Development") |
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" | |
| "log" | |
| "net/http" | |
| ) | |
| func indexHandler(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "Welcome to Go Web Development") |
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" | |
| "log" | |
| "net/http" | |
| ) | |
| type indexHandler struct { | |
| } |
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 Handler interface { | |
| ServeHTTP(ResponseWriter, *Request) | |
| } |