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
{ | |
"mitigation_matrix": { | |
"cloth": { | |
"piercing": 5, | |
"slashing": 1, | |
"blunt": 0, | |
"fire": -5, | |
"air": 0, | |
"water": 1, | |
"earth": 0 |
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
import ballerina/io; | |
function main(string... args) { | |
stream<string> userInput; | |
fork { | |
worker stdin_read { | |
while(true) { | |
io:println("Type something:"); |
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
import ballerina/grpc; | |
import ballerina/log; | |
import ballerinax/docker; | |
@docker:Expose {} | |
endpoint grpc:Listener listener { | |
host: "localhost", | |
port: 9090 | |
}; |
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
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"}; | |
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"; | |
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; |
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
@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; |
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
import ballerina/grpc; | |
import ballerina/log; | |
endpoint grpc:Listener listener { | |
host: "localhost", | |
port: 9090, | |
}; | |
map <DroneInfo> dronesMap; | |
type DroneInfo record { | |
string id; | |
string name; |
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
import ballerina/grpc; | |
endpoint grpc:Listener listener { | |
host: "localhost", | |
port: 9090 | |
}; | |
map <droneInfo> dronesMap; | |
type droneInfo record { |
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
fn get_library_entries( | |
&self, | |
ctx: RpcContext, | |
req: LibraryEntriesRequest, | |
resp: ServerStreamingSink<LibraryEntry>, | |
) { | |
info!( | |
"Handling get library entries request: {}", | |
req.get_agent_id() | |
); |
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
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, |