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
import ballerina/http; | |
http:Client webAppClient = check new("https://localhost:9090", | |
auth = { | |
tokenUrl: "https://localhost:9443/oauth2/token", | |
clientId: "FlfJYKBD2c925h4lkycqNZlC2l4a", | |
clientSecret: "PJz0UhTJMrHOo68QQNpvnqAY_3Aa", | |
scopes: ["customer"], | |
clientConfig: { | |
secureSocket: { |
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
import ballerina/grpc; | |
import ballerina/jwt; | |
listener grpc:Listener paymentsEP = new(9191, | |
secureSocket = { | |
key: { | |
certFile: "/path/to/public.crt", | |
keyFile: "/path/to/private.key" | |
} | |
} |
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
import ballerina/grpc; | |
GrpcClient clientEP = check new("https://localhost:9191", | |
auth = { | |
issuer: "order-service", | |
audience: ["payment-service", "delivery-service"], | |
keyId: "5a0b754-895f-4279-8843-b745e11a57e9", | |
jwtId: "JlbmMiOiJBMTI4Q0JDLUhTMjU2In", | |
customClaims: { "scp": "admin" }, | |
expTime: 3600, |
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
import ballerina/http; | |
listener http:Listener listenerEP = new(9091, | |
secureSocket = { | |
key: { | |
certFile: "/path/to/server-public.crt", | |
keyFile: "/path/to/server-private.key" | |
}, | |
mutualSsl: { | |
verifyClient: http:REQUIRE, |
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
import ballerina/http; | |
http:Client clientEP = check new("https://localhost:9092", | |
secureSocket = { | |
cert: "/path/to/client-public.crt", | |
key: { | |
certFile: "/path/to/server-public.crt", | |
keyFile: "/path/to/server-private.key" | |
} | |
} |
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
import ballerina/http; | |
import ballerina/graphql; | |
listener http:Listener apiGateway = new(9090, | |
secureSocket = { | |
key: { | |
certFile: "/path/to/public.crt", | |
keyFile: "/path/to/private.key" | |
} | |
} |
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
public type CustomEvictionPolicy object { | |
*cache:AbstractEvictionPolicy; | |
public function get(LinkedList list, Node node) { | |
// custom implementation related to updating the | |
// `LinkedList` based on the get operation. | |
} | |
} |
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
public type CustomCache object { | |
*AbstractCache; | |
private AbstractEvictionPolicy evictionPolicy; | |
private LinkedList list; | |
public function __init(AbstractEvictionPolicy evictionPolicy) { | |
self.evictionPolicy = evictionPolicy; | |
self.list = { |
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
cache:Error? result = cache.put("key1", "value1"); | |
if (result is cache:Error) { | |
// implement what to do, if any error happen when inserting | |
// item to the cache | |
} | |
any|cache:Error result = cache.get("key1"); | |
if (result is cache:Error) { | |
// implement what to do, if any error happen when retrieving | |
// item from the cache | |
} |
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
_ = check cache.put("key1", "value1"); | |
string value = <string> check cache.get("key1"); | |
_ = check cache.invalidate("key1"); | |
_ = check cache.invalidateAll(); | |
boolean hasKey = cache.hasKey("key1"); | |
string[] keys = cache.keys(); | |
int size = cache.size(); | |
int capacity = cache.capacity(); |
NewerOlder