Skip to content

Instantly share code, notes, and snippets.

View xlight05's full-sized avatar
👻
Living the life ;)

Anjana Supun xlight05

👻
Living the life ;)
View GitHub Profile
import ballerina/http;
import ballerinax/azure.openai.chat;
configurable string apiKey = ?;
final chat:Client chatClient = check new (
config = {
auth: {apiKey: apiKey}
},
serviceUrl = "https://ballerina.openai.azure.com/openai"
service /dashboard on ep {
resource function get .(@af:CosmosDBInput {
connectionStringSetting: "CosmosDBConnection",
databaseName: "reviewdb",
collectionName: "c1",
sqlQuery: "SELECT * FROM Items"
} Entry[] entries) returns @af:HttpOutput Entry[]|error {
return entries;
}
}
configurable string visionApp = ?;
configurable string subscriptionKey = ?;
configurable string blobStoreName = ?;
public type Entry record {
string id;
boolean isDog;
string imageUrl;
string description;
};
import ballerina/http;
import ballerinax/azure_functions as af;
listener af:HttpListener ep = new ();
service /reviews on ep {
resource function post upload(@http:Payload byte[]|error image, string name) returns @af:BlobOutput {path: "images/{Query.name}"} byte[]|error {
return image;
}
}
import ballerinax/azure_functions as af;
service / on new af:HttpListener() {
resource function get greeting() returns json {
return {message: "Hello world"};
}
}
import ballerina/http;
import ballerina/xmldata;
listener http:Listener securedEP = new(9090);
final http:Client nettyEP = check new("http://netty:8688");
service /transform on securedEP {
resource function post .(http:Request req) returns http:Response|http:BadRequest|error {
json payload = check req.getJsonPayload();
xml? xmlPayload = check xmldata:fromJson(payload);
if (xmlPayload is xml) {
http:Request clinetreq = new;
import ballerina/http;
listener http:Listener securedEP = new(9090);
final http:Client nettyEP = check new("http://netty:8688");
service /passthrough on securedEP {
resource function post .(http:Request req) returns http:Response|error{
return nettyEP->forward("/service/EchoService", req);
}
}
Label # Samples Average Median 90% Line 95% Line 99% Line Min Max Error % Throughput Received KB/sec Std. Dev. Date Payload Users Version
HTTP Request 5100456 17 11 41 56 99 0 559 0.00% 4722.8 705.4 20.99 1643799779 0 100 Ballerina 2201.0.0 (Swan Lake)
HTTP Request 6385840 9 2 20 42 129 0 1037 0.00% 5912.8 888.9 26.34 1643798268 0 100 Go 1.17.6
HTTP Request 3321815 32 29 46 52 73 0 358 0.00% 3075.9 699.7 11.74 1643805102 0 100 Node 14 Express 4.17
HTTP Request 6434065 12 5 30 49 109 0 918 0.00% 5957.7 895.7 22.44 1643803778 0 100 Node 14
HTTP Request 789197 136 133 152 163 185 103 257 0.00% 730.7 109.9 13.47 1643802424 0 100 Python 3.8 Flask 2.0
HTTP Request 29454 3662 3 15002 15004 15008 0 30031 24.04% 27.0 5.4 6428.67 1643801101 0 100 Python 3.8
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 18 columns, instead of 17. in line 7.
Scenario,Label,# Samples,Average,Median,90% Line,95% Line,99% Line,Min,Max,Error %,Throughput,Received KB/sec,Std. Dev.,Date,Payload,Users,Version
ballerina_hello,HTTP Request,4701750,12,8,26,35,63,0,488,0.00%,4353.7,650.3,13.07,1643775280,50,60,Ballerina Swan Lake Beta 1
h1_transformation,HTTP Request,2450106,24,18,48,69,138,1,983,0.00%,2268.7,606.9,26.89,1643776713,50,60,Ballerina Swan Lake Beta 1
h1c_h1c_passthrough,HTTP Request,2352595,26,19,56,64,82,1,208,0.00%,2178.4,387.1,19.92,1643778118,50,60,Ballerina Swan Lake Beta 1
h1c_transformation,HTTP Request,1818312,34,25,69,75,91,1,182,0.00%,1683.7,345.2,23.72,1643779552,50,60,Ballerina Swan Lake Beta 1
observability_enabled,HTTP Request,4672354,12,8,27,35,62,0,444,0.00%,4326.5,646.2,13.20,1643780967,50,60,Ballerina Swan Lake Beta 1
ballerina_hello,HTTP Request,4754335,12,8,26,35,60,0,457,0.00%,4402.5,657.6,12.85,1643786590,50,60,Ballerina Swan Lake Beta 6
h1_transformation,HTTP Request,2285054,27,22,50,67,109,1,644,0.00%,2115.9,578.5,21.31,1643723138,50,60
@xlight05
xlight05 / result.json
Created January 24, 2022 05:01
result.json
{ "results": [ { "name": "project-1", "status": "success", "result": "HTTP Request,3377166,63,13,283,326,349,0,1025,0.00%,3127.3,3731.8,101.75,1642319492,1024,50", "errorRate": "0.00" }, { "name": "project-2", "status": "success", "result": "HTTP Request,3377166,63,13,283,326,349,0,1025,0.00%,3127.3,3731.8,101.75,1642319492,1024,100", "errorRate": "0.00" }, { "name": "project-3", "status": "success", "result": "HTTP Request,3377166,63,13,283,326,349,0,1025,0.00%,3127.3,3731.8,101.75,1642319492,1024,200", "errorRate": "0.00" } ] }