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 reactor.core.publisher.Flux; | |
| import reactor.core.publisher.Mono; | |
| public interface PubSubService { | |
| Mono<Void> publish(Message message); | |
| } |
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 Mono<ChatRoom> getById(String id) { | |
| return Mono.defer(() -> { | |
| ApiFuture<DocumentSnapshot> chatRoomSnapshotFuture = | |
| firestore.collection(ServiceConstants.CHAT_ROOMS).document(id).get(); | |
| Mono<DocumentSnapshot> chatRoomSnapshotMono = ApiFutureUtil.toMono(chatRoomSnapshotFuture); | |
| return chatRoomSnapshotMono.map(chatRoomSnapshot -> | |
| new ChatRoom(chatRoomSnapshot.getId(), chatRoomSnapshot.getString("name"))); | |
| }); | |
| } |
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 com.google.api.core.ApiFuture; | |
| import com.google.api.core.ApiFutureCallback; | |
| import com.google.api.core.ApiFutures; | |
| import reactor.core.publisher.Mono; | |
| public class ApiFutureUtil { | |
| public static <T> Mono<T> toMono(ApiFuture<T> apiFuture) { | |
| return Mono.create(sink -> { | |
| ApiFutureCallback<T> callback = new ApiFutureCallback<T>() { | |
| @Override |
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 Mono<ChatRoom> getById(String id) { | |
| ApiFuture<DocumentSnapshot> chatRoomSnapshotFuture = | |
| firestore.collection(ServiceConstants.CHAT_ROOMS).document(id).get(); | |
| Mono<DocumentSnapshot> chatRoomSnapshotMono = ApiFutureUtil.toMono(chatRoomSnapshotFuture); | |
| return chatRoomSnapshotMono.map(chatRoomSnapshot -> | |
| new ChatRoom(chatRoomSnapshot.getId(), chatRoomSnapshot.getString("name"))); | |
| } |
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 ChatRoom getById(String id) { | |
| ApiFuture<DocumentSnapshot> chatRoomSnapshotFuture = | |
| firestore.collection(ServiceConstants.CHAT_ROOMS).document(id).get(); | |
| try { | |
| DocumentSnapshot chatRoomSnapshot = chatRoomSnapshotFuture.get(); | |
| return new ChatRoom(chatRoomSnapshot.getId(), chatRoomSnapshot.getString("name")); | |
| } catch (Exception e) { | |
| throw new RuntimeException("Could not retrieve by id", e); | |
| } | |
| } |
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
| gcloud compute instances create europe-north1-a-instance \ | |
| --zone=europe-north1-a --machine-type=e2-micro \ | |
| --create-disk=image=projects/debian-cloud/global/images/debian-10-buster-v20211209,mode=rw | |
| gcloud compute ssh europe-north1-a-instance --zone=europe-north1-a | |
| curl 'http://ANYCAST_OP/caller/messages' \ | |
| -H 'Content-Type: application/json' \ | |
| -H 'Accept: */*' \ |
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
| gcloud compute instances create us-west1-a-instance \ | |
| --zone=us-west1-a --machine-type=e2-micro \ | |
| --create-disk=image=projects/debian-cloud/global/images/debian-10-buster-v20211209,mode=rw | |
| gcloud compute ssh us-west1-a-instance --zone=us-west1-a | |
| ## From the instance.. | |
| curl 'http://ANYCAST_IP/caller/messages' \ | |
| -H 'Content-Type: application/json' \ | |
| -H 'Accept: */*' \ |
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
| apiVersion: networking.gke.io/v1 | |
| kind: MultiClusterService | |
| metadata: | |
| name: sample-caller-mcs | |
| namespace: istio-apps | |
| spec: | |
| template: | |
| spec: | |
| selector: | |
| app: sample-caller |
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
| apiVersion: networking.gke.io/v1 | |
| kind: MultiClusterIngress | |
| metadata: | |
| name: sample-caller-ingress | |
| namespace: istio-apps | |
| spec: | |
| template: | |
| spec: | |
| backend: | |
| serviceName: sample-caller-mcs |
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
| const { run_v1, google } = require('googleapis'); | |
| const { ProjectsClient } = require('@google-cloud/resource-manager'); | |
| exports.scanAndDeletePreviewServices = async (message, context) => { | |
| const auth = new google.auth.GoogleAuth({ | |
| scopes: ['https://www.googleapis.com/auth/cloud-platform'] | |
| }) | |
| const defaultOptions = { | |
| rootUrl: 'https://us-central1-run.googleapis.com' | |
| } |