Skip to content

Instantly share code, notes, and snippets.

View autodidaddict's full-sized avatar
🚀
Shipping software

Kevin Hoffman autodidaddict

🚀
Shipping software
View GitHub Profile
@autodidaddict
autodidaddict / keybase.md
Created February 21, 2017 20:42
Keybase proof

Keybase proof

I hereby claim:

  • I am autodidaddict on github.
  • I am autodidaddict (https://keybase.io/autodidaddict) on keybase.
  • I have a public key ASAutaH5uQpgRtlgvounqqJWTywNRFZfzks7qfWBLwZX7go

To claim this, I am signing this object:

@autodidaddict
autodidaddict / threads.rs
Created March 5, 2018 19:28
Mutating Data with Multiple Threads in Rust - Channels vs Mutexes
use std::thread::spawn;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::mpsc;
#[derive(Debug)]
struct Transaction {
amount: isize,
timestamp: u64,
txid: String,
fn get_library_entries(
&self,
ctx: RpcContext,
req: LibraryEntriesRequest,
resp: ServerStreamingSink<LibraryEntry>,
) {
info!(
"Handling get library entries request: {}",
req.get_agent_id()
);
@autodidaddict
autodidaddict / drone_mgmt_svc.bal
Created July 23, 2018 11:13
Ballerina gRPC attempt
import ballerina/grpc;
endpoint grpc:Listener listener {
host: "localhost",
port: 9090
};
map <droneInfo> dronesMap;
type droneInfo record {
@autodidaddict
autodidaddict / dronemgmt1.bal
Created July 27, 2018 18:31
gRPC Ballerina Blog Posts - 1
import ballerina/grpc;
import ballerina/log;
endpoint grpc:Listener listener {
host: "localhost",
port: 9090,
};
map <DroneInfo> dronesMap;
type DroneInfo record {
string id;
string name;
@autodidaddict
autodidaddict / dronemgmt2.bal
Created July 27, 2018 18:33
gRPC Ballerina Blog Posts - 2
@grpc:ServiceConfig
service DroneMgmt bind listener {
GetDrone(endpoint caller, string droneId) {
DroneInfo info = dronesMap[droneId] but { ()=>{} };
_ = caller->send(info);
_ = caller->complete();
}
AddDrone(endpoint caller, DroneInfo droneReq) {
string droneId = droneReq.id;
dronesMap[droneId] = droneReq;
@autodidaddict
autodidaddict / dronemgmt3.proto
Last active July 27, 2018 18:34
gRPC Ballerina Blog Posts - 3
syntax = "proto3";
import "google/protobuf/wrappers.proto";
service DroneMgmt {
rpc GetDrone(google.protobuf.StringValue) returns (DroneInfo);
rpc AddDrone(DroneInfo) returns (DroneInfo);
rpc UpdateDrone(DroneInfo) returns (DroneInfo);
}
message DroneInfo {
string id = 1;
string name = 2;
@autodidaddict
autodidaddict / dronemgmt4.bal
Created July 27, 2018 18:35
gRPC Ballerina Blog Posts - 4
import ballerina/io;
import ballerina/log;
import ballerina/grpc;
function main(string... args) {
endpoint DroneMgmtBlockingClient droneMgmtBlockingEp {
url: "http://localhost:9090"
};
DroneInfo req = {battery_remaining: 12, id: "DRONE1",
name: "Drone One"};
@autodidaddict
autodidaddict / dronemgmt.bal
Created August 6, 2018 12:13
Updated drone management service with Docker annotations
import ballerina/grpc;
import ballerina/log;
import ballerinax/docker;
@docker:Expose {}
endpoint grpc:Listener listener {
host: "localhost",
port: 9090
};
@autodidaddict
autodidaddict / workers.bal
Created August 14, 2018 00:14
Ballerina workers sample
import ballerina/io;
function main(string... args) {
stream<string> userInput;
fork {
worker stdin_read {
while(true) {
io:println("Type something:");