Build a home media server but automated

Intro In Route transmission to VPN container, I talked about how to download contents via VPN tunnel so we can get rid of some troubles. But that is far from enough for us to build a home media server which should work as Netflix and Hulu to us. We shouldn’t bother with the torrent and subtitle search. Once we add a show to our watch list, everything should be set up automatically....

September 16, 2023 · 3 min · 623 words · Me

Expose NAS Services with Att Gateway

Recently I changed my ISP to ATT to try their fiber, and they gave me the bgw320 as the gateway for the Internet service. And I have trouble connecting to my Synology’s services like Jellyfin. I suspect it has some conflicts with the network of these docker services running in Synology or the internet setup of Synology. Considering the configuration of docker network could be another rabbit hole, I didn’t go that route....

September 16, 2023 · 1 min · 210 words · Me

FLP impossibility in plain language

Overview FLP impossibility is to prove there is no algorithm can really achieve totally correct consensus in asychronous system under assumption at most one process is faulty. The paper is very famous and also difficult to understand given the wording. This article is to explain FLP impossibility in a plain way. Aschronous System In FLP paper, there are some settings/assumptions made to describe an aschronous system which is used in the proof....

September 16, 2023 · 7 min · 1468 words · Me

gRPC tutorial - 1: Overview

What is gRPC gRPC is a high performance open-source freature-rich RPC (remote procedure calls) framework developed by google. “g” stands for many different meaning like green, good and etc. It is a protocal that allows a program to execute a procedure of another program located in other computer without the developer explicitly coding the details for the remote interaction gRPC is one kind of s2s call and widely used to replace REST API in the backend due to:...

September 16, 2023 · 2 min · 362 words · Me

gRPC tutorial - 2: Enviroment Setup

Environment Setup I am using Gradle and Intellij Idea for this project (Maven setting can be found here). The Gradle setting is shown as following: plugins { id "com.google.protobuf" version "0.8.18" id "java" } group 'today.ihelio.grpc.tutorial' version '1.0-SNAPSHOT' sourceCompatibility = 15 repositories { mavenCentral() } dependencies { implementation 'junit:junit:4.13.1' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.21.4' runtimeOnly group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.21.4' implementation group: 'io.grpc', name: 'grpc-all', version: '1....

September 16, 2023 · 3 min · 463 words · Me

gRPC tutorial - 3: Unary Call

Unary call is very simple to understand, it is essentially a normal REST API call. Each request will get a single response from the server. In this project, we implement unary call to create books in our store. First, we need create book_message.proto which is a book pojo carrying the related info of book. Simply speaking, each message is pojo we are gonna use in our service. syntax = "proto3"; package book; option java_multiple_files = true; option java_package = "today....

September 16, 2023 · 7 min · 1312 words · Me

gRPC tutorial - 4: Client Streaming

We will implement a function to upload image when we create the books like the cover and something else. And we would split the image into chunks and we upload them chunk by chunk until all data are transfered. As we defined earlier in the proto, we could have multiple images for one book. So we will need a function called uploadImage and uploade all images one by one. Let’s start with the proto of image:...

September 16, 2023 · 8 min · 1656 words · Me

gRPC tutorial - 5: Server Streaming

Regarding server streaming, we will implement a simplified recommendation service to recommend the books based on the popularity. Like client streaming, we would need a response handler - StreamObserver<RecommendBookResponse> - to handle a sequential of responses given one request. Since this is a recommendation function, we would need search the books from our book store given the criteria. Thus we would need add a searchBook method to our book store....

September 16, 2023 · 3 min · 625 words · Me

gRPC tutorial - 6: Bidirectional streaming

We will speed it up a bit in this chapter after implementing unary call and one direction streaming. As always, we need implement our core logic which includes our book store which handles rating update and computing and book service which handls the request and return response. @Override public Book rateBook(String bookID, Integer rating) { Book book = inMemoryBookStore.getOrDefault(bookID, null); if (book == null) { throw NOT_FOUND.withDescription("book not found") .asRuntimeException(); } inMemoryBookStore....

September 16, 2023 · 3 min · 427 words · Me

gRPC tutorial - 7: Takeaway

The four types of gRPC covers the majority use case when we design API under HTTP/2 since we could either send one request/response or multiple requests/responses in one call. And using proto buffer enables us to separate the implementation of service, server and client which are the three components we need develop for each RPC service. Though the service could also depend on several components. But the idea is the simple, we need implement service, server and client for each RPC service and we don’t have to stick with one language for server and client....

September 16, 2023 · 3 min · 447 words · Me