This file contains 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
open Lwt | |
(* Shared mutable counter *) | |
let counter = ref 0 | |
let listen_address = Unix.inet_addr_loopback | |
let port = 9000 | |
let backlog = 10 |
This file contains 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"; | |
option go_package = "gihthub.com/aryangodara/go-kit-grpc-example1/pb"; | |
service MathService { | |
rpc Add(MathRequest) returns (MathResponse); | |
rpc Subtract(MathRequest) returns (MathResponse); | |
rpc Multiply(MathRequest) returns (MathResponse); | |
rpc Divide(MathRequest) returns (MathResponse); | |
} |
This file contains 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 service | |
import ( | |
"context" | |
"github.com/go-kit/log" | |
) | |
type service struct { | |
logger log.Logger |
This file contains 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 endpoints | |
import ( | |
"context" | |
"github.com/aryangodara/go-kit-grpc-example1/api/service" | |
"github.com/go-kit/kit/endpoint" | |
) | |
// Endpoints struct holds a list of endpoints |
This file contains 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 transports | |
import ( | |
"context" | |
"errors" | |
"github.com/aryangodara/go-kit-grpc-example1/api/endpoints" | |
"github.com/aryangodara/go-kit-grpc-example1/pb" | |
gt "github.com/go-kit/kit/transport/grpc" | |
"github.com/go-kit/log" |
This file contains 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" | |
"net" | |
"os" | |
"os/signal" | |
"syscall" | |
"github.com/aryangodara/go-kit-grpc-example1/api/endpoints" |
This file contains 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
open Lwt.Infix | |
let listen_address = Unix.inet_addr_loopback | |
let port = 9000 | |
let handle_message msg = | |
print_endline ("Received message in handle_message: " ^ msg); | |
match msg with "quit" -> "quit" | _ -> "Ready for next message" | |
let rec handle_request server_socket = |
This file contains 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
let () = | |
print_endline "Launching UDP Client..."; | |
let () = Logs.set_reporter (Logs.format_reporter ()) in | |
let () = Logs.set_level (Some Logs.Info) in | |
let client_socket = Client.create_socket () in | |
Lwt_main.run Client.(create_client client_socket) |
This file contains 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
let () = | |
print_endline "Launching UDP Server..."; | |
let () = Logs.set_reporter (Logs.format_reporter ()) in | |
let () = Logs.set_level (Some Logs.Info) in | |
let server_socket = Server.create_socket () in | |
Lwt_main.run Server.(create_server server_socket) | |
This file contains 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
open Lwt.Infix | |
(* Shared mutable counter *) | |
let counter = ref 0 | |
(* This defines a shared mutable counter initialized to 0 using a reference cell. *) | |
let listen_address = Unix.inet_addr_loopback | |
(* This sets the listen_address to the loopback IP address (127.0.0.1), indicating | |
that the server will listen for connections from the local machine only. *) |
OlderNewer