Automating Docker Publishing With GitHub Action

Recently, I’ve been using GitHub Actions for my company’s internal project release process, and it’s been a great experience. The main goal of this article is to help newcomers to GitHub Actions to quickly build automated tests and package and push Docker images. Create project This article focuses on Go as an example, but of course other languages are similar and have little to do with the language itself. Here we start by creating a project on GitHub and writing a few simple pieces of code main.

Redis6 Client Side Caching Features and Practices

Redis 6.0 has been released more than a year ago. The new features in Redis 6.0 have been identified through step-by-step discussions and optimizations. Many of these features have already been introduced in previous releases such as RC. However, there are some new changes in the official GA release: SSL ACL: better, command support RESP3 Client side caching: redesigned Threaded I/O Diskless replication on replicas Cluster support in Redis-benchmark and improved redis-cli cluster support Disque in beta as a module of Redis: starting to invade the message queue space Redis Cluster Proxy Support for immediate deletion when the RDB is no longer in use, for scenarios where the disk is not dropped PSYNC2: Optimized replication protocol More friendly timeout setting support Faster RDB loading, 20% ~ 30% improvement STRALGO, new string command, currently only one implementation of LCS (longest common subsequence) @antirez mentioned that it was only the largest version update in Redis history, so it was prudent to recommend more testing and evaluation of the product in the application, and promised to release version 6.

Data Reading in Golang

The standard library of Go provides several methods to read data from io.Reader (io, ioutil), and this article demonstrates the application scenarios by reading data from net. Accessing a website using a TCP connection, using the HTTP 1.0 protocol, keeping the TCP connection short and closing it after reading the response, thus simulating the io.EOF error. 1 2 3 4 5 6 conn, err := net.Dial("tcp", "") if err != nil { fmt.

The Type System of Javascript

Overview The type judgment of JavaScript is a necessary part of the front-end engineers’ code every day, and every day they must write a if (a === 'xxx') or if (typeof a === 'object') similar type judgment statement, so mastering the type judgment of JavaScript is also a necessary skill for the front-end, the following will be from the type of JavaScript, type judgment and some internal implementation to give

Android Surfaceview Source Code Analysis and Use

SurfaceView is a special kind of view in Android. The biggest difference between it and TextView and Button is that it is not on the same view layer as its view container, and its UI display can be done in a separate thread, so the drawing of SurfaceView does not affect the main thread. surfaceView does not affect the main thread. Combining these features, SurfaceView is generally used to implement dynamic or complex images and animations.

Web Worker Tutorial

1. Overview The JavaScript language uses a single-threaded model, which means that all tasks can only be done on one thread, one thing at a time. If the previous task is not done, the later task has to wait. With the increase in computing power of computers, especially with the advent of multi-core CPUs, single-threading poses a great inconvenience and cannot fully utilize the computing power of computers. The role of the Web Worker is to create a multi-threaded environment for JavaScript, allowing the main thread to create Worker threads and assign some tasks to the latter to run.

Build an Etcd Cluster With Etcdadm

1. Introduction In the process of building a Kubernetes cluster, the first thing to do is to fix the Etcd cluster. Although the kubeadm tool already provides an automatic way to build the Etcd cluster that is bound to the master node by default, I personally always manually build the Etcd cluster on the host; because this thing is so important, it is no exaggeration to say that It is

MySQL Crash Safe

The MySQL master-slave architecture has been widely used, and the stability of the master-slave replication relationship is a constant concern. MySQL 5.6 provides a new feature for master-slave replication stability: slave support crash-safe. This feature can solve the problem of bit inaccuracy caused by abnormal power failure in previous versions. In this article, we will introduce this feature in terms of principle, parameters, and new issues. Translated with (free version)

Kubernetes Switching to Containerd

1. Environmental preparation Ubuntu 20.04 x5 Etcd 3.4.16 Kubernetes 1.21.1 Containerd 1.3.3 1.1. Handling IPVS Since the new version of Kubernetes Service implementation switches to IPVS, you need to make sure the kernel has IPVS modules loaded; the following command will set the system to automatically load IPVS related modules at boot, and you need to reboot after execution. 1 2 3 4 5 6 7 8 9 10 11

Npx Tutorial

The npx command has been added to npm since version 5.2. It has many uses, and this article introduces the main usage scenarios of the command. Node comes with an npm module, so you can use the npx command directly. In case it doesn’t work, you’ll have to install it manually. 1 $ npm install -g npx Calling the project’s installed modules The main problem that npx is trying to solve is calling modules that are installed inside the project.

Implementing Lock Free Queues With Go

A queue is a very common data structure that allows only outgoing (dequeue) operations at the front end of a table (head) and incoming (enqueue) operations at the back end of a table (tail). Like the stack data structure, a queue is a linear table with restricted operations. The end that performs the insert operation is called the tail and the end that performs the delete operation is called the header.

Spring Cloud Gateway Custom Exception Handling

When we usually use SpringMVC, as long as the request is processed by DispatcherServlet, you can customize the handling logic of different types of exceptions through @ControllerAdvice and @ExceptionHandler, you can refer to ResponseEntityExceptionHandler and DefaultHandlerExceptionResolver, the underlying principle is very simple, that is, when an exception occurs, search for the exception handler that already exists in the container and match the corresponding exception type, after a successful match, use

Spring Cloud Gateway-ServerWebExchange Core Methods and Request or Response Content Modification

Prerequisites This article was written using Spring Cloud Gateway version Greenwich.SR1. When we use Spring Cloud Gateway, we notice that the filters (including GatewayFilter, GlobalFilter and the filter chain GatewayFilterChain), all depend on the ServerWebExchange. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 public interface GlobalFilter { Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain); } public interface GatewayFilter extends ShortcutConfigurable { Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain);

Golang Context Source Code Analysis

All source code analysis in this article is based on Go 1.16.4. 1. Context Introduction Context in the standard library is an interface with various implementations; Context was added to the standard library in Go 1.7 and is mainly used for setting deadlines, synchronizing signals, passing context request values, etc. across multiple Goroutines. Because of the need to pass signals across multiple Goroutines, multiple Contexts often need to be associated

Lazy Lists Based on Generator and Iterator

If you know Haskell, you are familiar with the following expressions 1 2 3 repeat 1 -- => [1, 1, 1, 1, 1,...] cycle "abc" -- => "abcabcabc..." [1, 3..] -- => [1, 3, 5, 7, ...] Several of the above expressions produce infinite lists. For those of you who are used to mainstream programming voices may be confused as to how the concept of infinity can be expressed inside a finite amount of memory.


Starting with React 16.3, React deprecated some APIs (componentWillMount, componentWillReceiveProps, and componentWillUpdate) and introduced some new ones instead, including getDerivedStateFromProps. getDerivedStateFromProps. Depending on the application scenario, getDerivedStateFromProps is used in different ways. Semi-controlled components Although React officially does not recommend semi-controlled components, and certainly not from the perspective of API design and maintenance. However, in practice, users often don’t care about the internal implementation of a business logic, but want to have full control over some internal state when needed, so semi-controlled components are a good choice.

Elegant Stopping Springboot Application

The closing of SpringBoot applications is currently summarized in four ways. Rest api: use the spring-boot-starter-actuator module in the ShutdownEndpoint the exit static method of SpringApplication: just call the static method directly JMX: use the MXBean provided inside SpringBoot. use third-party process management tools Rest api The Rest api is exposed using Endpoint and requires the introduction of spring-boot-starter-actuator the stater. The corresponding Endpoint for this shutdown application is ShutdownEndpoint,

Go Implements Prioritization in Select Statements

This article reviews some of the uses of the select statement in the Go language and extends a tip on how to implement priority in select, which I hope will be helpful to you. Introduction to the select statement The select statement in Go is used to monitor and select a set of case statements to execute the corresponding code. It looks similar to the switch statement, but all the expressions in the case in the select statement must be send or receive operations of the channel.

Go Reflect Performance

Go reflect package provides the ability to get the type and value of an object at runtime, which can help us to abstract and simplify the code, achieve dynamic data acquisition and method invocation, improve development efficiency and readability, and make up for Go’s ability to handle data uniformly in the absence of generics. With reflect, we can achieve the ability to get object types, object fields, object methods, get tag information of struct, dynamically create objects, whether objects implement specific interfaces, convert objects, get and set object values, call Select branches dynamically, etc.

Tracking Users via Js

This article describes how to write JavaScript scripts to send user data back to the server. I made a code repository containing all the examples below, which can be run to see the results. 1. Synchronization AJAX The common practice of sending data back to the server is to put the collected user data inside the unload event and send it back to the server with an AJAX request. However, asynchronous AJAX inside the unload event may not always work, because the page is already in unload and the browser may or may not send it.