Dateparse Usage Guide

Handling time is always a headache, no matter what time it is. The time format is too diverse, and it is even more difficult to deal with time zones, daylight saving time, leap seconds and other minor details. Therefore, we usually use standard libraries or time libraries provided by third parties to handle time in our programs. The dateparse we are going to introduce today focuses on a very small area of time processing - parsing strings in date time format.

Go Channel vs Java BlockingQueue

Recently, I was implementing two requirements and wanted to decouple them using a queue since there is no dependency between them; however, there is no readily available and concurrency-safe data structure in Go’s standard library; however, Go provides a more elegant solution, which is channel. Using Channel One of the major differences between Go and Java is the different concurrency model; Go uses the CSP (Communicating sequential processes) model; in

Building an AWS Local Development Environment with Localstack

I believe there are many people who have used AWS for their projects or are learning AWS. We know that with cloud services like AWS, it’s not very easy to connect to the cloud when developing locally, not to mention that the staging/production environment will have security considerations. So when we create a project, how do we build its local development environment to facilitate our local development and debugging? That’s right!

Getting Started With Mockoon

Sometimes I run into the need to build a quick test service, like this. Build an HTTP Service, which can be run locally, but also needs to be accessible on the public network, and request the service to get a custom set of JSON data. For no other reason than to be able to use it for testing quickly. At this time I want to complete in the shortest possible time, such as a minute to write it, how can I do this time?

Spring Cloud Gateway Guide

Recently, I was working on the refactoring of the old system, and I needed to introduce a gateway service into the new system after the refactoring was completed, as an adaptation and proxy for the interface between the new system and the old system. Previously, many gateway applications used the Spring-Cloud-Netfilx solution based on the Zuul1.x version, but given that Zuul1.x had stopped iterating, it used a more traditional blocking

Spring Cloud Gateway Custom Globalfilter

The scope of GlobalFilter is all the routing configuration, we can do additional extensions by customizing GlobalFilter, which can be used to implement some global functions. How to customize GlobalFilter The interface definition for org.springframework.cloud.gateway.filter.GlobalFilter is as follows. 1 2 3 4 public interface GlobalFilter { Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain); } We just need to implement the org.springframework.cloud.gateway.filter.GlobalFilter interface and register the implementation class in Spring’s container, the official example is as follows.

Pulsar Getting Started and Introduction

We are recently doing the technology selection for new business, which involves the selection of messaging middleware; combined with our actual situation we hope it can meet the following requirements. Cloud-friendly native support: because the main language is now Go, while being able to be simple enough in terms of operation and maintenance. Official SDK support for multiple languages: There is still some Python, Java related code to maintain. Preferably with some convenient and useful features, such as: delayed messages, dead letter queues, multi-tenancy, etc.

Various Database Connection Strings Commonly Used by Go

1. Relational Databases 1.1 MySQL https://github.com/go-sql-driver/mysql/ 1 2 3 4 5 6 7 8 9 10 11 12 [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN] // user@unix(/path/to/socket)/dbname // root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local // user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true // user:password@/dbname?sql_mode=TRADITIONAL // user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_unicode_ci // id:password@tcp(your-amazonaws-uri.com:3306)/dbname // user@cloudsql(project-id:instance-name)/dbname // user@cloudsql(project-id:regionname:instance-name)/dbname // user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped // user:password@/dbname // user:password@/ 1.2 Postgres (pure Go) https://github.com/lib/pq 1 2 3 4 5 6 7 8 9 postgres://[user[:password]@][netloc][:port][,...][/dbname][?param1=value1&...] postgres:// postgres://localhost postgres://localhost:5433 postgres://localhost/mydb postgres://user@localhost postgres://user:secret@localhost postgres://other@localhost/otherdb?connect_timeout=10&application_name=myapp postgres://host1:123,host2:456/somedb?target_session_attrs=any&application_name=myapp 1.3 SQLite (uses cgo) https://github.com/mattn/go-sqlite3 1 2 3 4 test.

Notes on the Use of Feign and Restful Design Specifications

I recently used Spring Cloud Feign as an HTTP client in a lot of projects, and encountered a lot of pitfalls, and also generated some ideas about RESTFUL design, which I’d like to document here. SpringMVC’s request parameter binding mechanism Users who know the history of Feign will know that Feign itself is a Netflix product, Spring Cloud Feign is based on the native Feign encapsulation, the introduction of a large number of SpringMVC annotation support, making it easier to use by the majority of Spring users, but also produced a not small confusing effect.

Spring Cloud Gateway - Downgrading with Hystrix using Custom Filters

Prerequisites In microservices architecture, if the downstream dependencies do not do request degradation processing, the downstream abnormal dependencies are not isolated, and it is likely that one or two services or as small as one or two interface abnormalities will lead to the unavailability of all upstream services and even affect the whole business line. Request degradation processing is still relatively mainstream is Netfilx produced Hystrix. Hystrix works on the

Introduction to Spring Cloud Stream

Spring Cloud Stream is used within the Spring Cloud architecture to build highly scalable, event-driven microservices. There is a lot of content in Spring Cloud Stream itself and it has many external dependencies. To get familiar with Spring Cloud Stream, you need to know the following. Spring Framework(Spring Messaging, Spring Environment) Spring Boot Actuator Spring Boot Externalized Configuration Spring Retry Spring Integration Spring Cloud Stream The purpose of this article is to introduce Spring Cloud Stream, and with so much knowledge, we will try to take you through Spring Cloud Steam in the simplest way possible (we will replace Spring Cloud Stream with SCS later).

A pitfall of comparing empty structs in Golang

A reader recently encountered a new problem with struct that he could not solve. Examples of Doubt The example 1 it gives is as follows. 1 2 3 4 5 6 7 type People struct {} func main() { a := &People{} b := &People{} fmt.Println(a == b) } What do you think the output will be? The output is: false. With a little more modification, Example 2 is as

Docker Serious Error Causes Enterpris Data to Be Deleted by Hackers

Be cautious of popular technologies that promise to make work easy - they often cut corners, and security is often one of them. A few days ago, the database of NewsBlur (a web-based RSS reader) was deleted by a hacker due to a bug that existed in Docker for years. In a blog post this week, NewsBlur founder Samuel Clay detailed his ordeal: during a migration of a MongoDB cluster to a Docker container, a hacker gained access to the NewsBlur database, deleted 250GB of raw data, and demanded a 0.

Finding the Kth Largest Number in a Large Amount of Unordered Data

Find the Kth largest value in an unordered long array of millions. The requirement is, of course, that the faster you find it, the better. top K questions As soon as the problem is described, many people will associate it with the top K problem, which is discussed extensively in both the algorithm and engineering fields, and it is easy to encounter similar problems in actual projects, so I also took the opportunity to summarize it into an article.

Golang Cron V3 Timed Tasks

Recently I need to use the timed task function in golang, I use a cron library, the current version is v3, the Internet is quite a lot of v2 tutorials, record the use of the method. In the old version of the library, the default cron expression is not the standard format, the first bit is the definition of the second level. Now the v3 version can use the standard cron expression directly, mainly see the godoc documentation section

Web Components Getting Started Example Tutorial

Components are the direction of front-end development, and the popular React and Vue are both component frameworks. Google has been pushing for native components for browsers due to its mastery of the Chrome browser, namely the Web Components API. Compared to third-party frameworks, native components are simple and straightforward, intuitive, don’t have to load any external modules, and have a small amount of code. It is still evolving, but is

Introduction to Spring Cloud Bus

The Spring Cloud Bus positions itself as a messaging bus within the Spring Cloud system, using a message broker to connect all nodes of a distributed system. The official Reference documentation for the Bus is relatively simple, so simple that it doesn’t even have a diagram. This is the most 2.1.0 version of the Spring Cloud Bus code structure (less code) Bus Example Demonstration Before we analyze the implementation of the Bus, let’s look at two simple examples of using Spring Cloud Bus.

Build Streaming Applications Based on Flink Sql

Since the release of Flink 1.10.0, many exciting new features have been released. In particular, the Flink SQL module is evolving very fast, so this article is dedicated to exploring how to build a fast streaming application using Flink SQL from a practical point of view. This article will use Flink SQL to build a real-time analytics application for e-commerce user behavior based on Kafka, MySQL, Elasticsearch, Kibana. All the

Pitfalls of os.popen function and Pipe in Python

I recently wrote a few simple scripts in Python to process some data, and since it’s just a simple function, I just use print to print the log. The task occasionally throws some exceptions when running. Because I have print logs in different places, the place where the error is reported is not quite the same every time, which leads to very strange results; sometimes this piece of code is

Tutorials for using resty

resty is an HTTP client library for the Go language. resty is powerful and feature-rich. It supports almost all HTTP methods (GET/POST/PUT/DELETE/OPTION/HEAD/PATCH, etc.) and provides an easy-to-use API. Quick Use The code in this article uses Go Modules. Create the directory and initialize. 1 2 $ mkdir resty && cd resty $ go mod init github.com/darjun/go-daily-lib/resty Install the resty library. 1 $ go get -u github.com/go-resty/resty/v2 Here we get the information on the first page of Baidu.