Paster 服务端核心模块,使用字节跳动开源的微服务 RPC 框架 KiteX ,以 Apache Thrift 作为通信协议

Overview

paster_core

Paster 服务端核心模块,使用字节跳动开源的微服务 RPC 框架 KiteX ,以 Apache Thrift 作为通信协议。

Todo:

  • 实现 KiteX 服务注册扩展接口,使用 Consul 服务注册
  • 新增 frame 层,通过 PreProcessor, PostProcessor 优化 KiteX 框架请求处理日志
  • 利用 SQLite 生成 .db 文件,初始化 MySQL
  • 将项目打包成 Dokcer 镜像
  • ...

Sequence Diagram

namespace go ameidance.paster.core

enum LanguageType {
    PLAIN = 0
    CPP = 1
    JAVA = 2
    PYTHON = 3
    GO = 4
    MD = 5
}

struct PostInfo {
    1: required string Content
    2: required LanguageType Language
    3: required string Nickname
    4: required bool IsDisposable
    5: optional i64 CreateTime
}

struct CommentInfo {
    1: required string Content
    2: required string Nickname
    3: optional i64 CreateTime
}

struct GetPostRequest {
    1: required i64 Id
    2: optional string Password
}

struct GetPostResponse {
    1: optional PostInfo Info
    254: required i32 StatusCode
    255: required string StatusMessage
}

struct SavePostRequest {
    1: required PostInfo Info
    2: optional string Password
}

struct SavePostResponse {
    1: optional i64 Id
    254: required i32 StatusCode
    255: required string StatusMessage
}

struct DeletePostRequest {
    1: required i64 Id
}

struct DeletePostResponse {
    254: required i32 StatusCode
    255: required string StatusMessage
}

struct GetCommentsRequest {
    1: required i64 PostId
    2: optional string Password
}

struct GetCommentsResponse {
    1: optional list Info
    254: required i32 StatusCode
    255: required string StatusMessage
}

struct SaveCommentRequest {
    1: required CommentInfo Info
    2: required i64 PostId
    3: optional string Password
}

struct SaveCommentResponse {
    254: required i32 StatusCode
    255: required string StatusMessage
}

service PasterCoreService {
    GetPostResponse GetPost(1: GetPostRequest req)
    SavePostResponse SavePost(1: SavePostRequest req)
    DeletePostResponse DeletePost(1: DeletePostRequest req)
    GetCommentsResponse GetComments(1: GetCommentsRequest req)
    SaveCommentResponse SaveComment(1: SaveCommentRequest req)
}

ER Diagram

SET NAMES utf8mb4;
SET
FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for comment
-- ----------------------------
DROP TABLE IF EXISTS `comment`;
CREATE TABLE `comment`
(
    `id`          bigint                                                       NOT NULL AUTO_INCREMENT COMMENT '评论自增 ID',
    `post_id`     bigint                                                       NOT NULL COMMENT '文本自增 ID',
    `content`     text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '评论内容',
    `nickname`    varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '评论人昵称',
    `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
    `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY           `idx_fk_post_id` (`post_id`),
    CONSTRAINT `idx_fk_post_id` FOREIGN KEY (`post_id`) REFERENCES `post` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Table structure for post
-- ----------------------------
DROP TABLE IF EXISTS `post`;
CREATE TABLE `post`
(
    `id`            bigint                                                       NOT NULL AUTO_INCREMENT COMMENT '文本自增 ID',
    `content`       text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文本内容',
    `lang`          smallint                                                     NOT NULL DEFAULT '0' COMMENT '文本语言',
    `passwd`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci         DEFAULT NULL COMMENT '密码',
    `nickname`      varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文本作者昵称',
    `is_disposable` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否阅后即焚',
    `create_time`   timestamp NULL DEFAULT NULL COMMENT '创建时间',
    `update_time`   timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

SET
FOREIGN_KEY_CHECKS = 1;
Issues
A native Thrift package for Go

Thrift Package for Go API Documentation: http://godoc.org/github.com/samuel/go-thrift License 3-clause BSD. See LICENSE file. Overview Thrift is an ID

Samuel Stauffer 347 Jul 14, 2021
Netpoll is a high-performance non-blocking I/O networking framework, which focused on RPC scenarios, developed by ByteDance.

Netpoll is a high-performance non-blocking I/O networking framework, which focused on RPC scenarios, developed by ByteDance. RPC is usually heavy on processing logic and therefore cannot handle I/O serially. But Go's standard library net designed blocking I/O API, so that the RPC framework can only follow the One Conn One Goroutine design.

CloudWeGo 446 Jul 17, 2021
Simple, fast and scalable golang rpc library for high load

gorpc Simple, fast and scalable golang RPC library for high load and microservices. Gorpc provides the following features useful for highly loaded pro

Aliaksandr Valialkin 637 Jul 7, 2021
Easily generate gRPC services in Go ⚡️

Lile is a application generator (think create-react-app, rails new or django startproject) for gRPC services in Go and a set of tools/libraries. The p

Lile 1.3k Jul 18, 2021
A pluggable backend API that enforces the Event Sourcing Pattern for persisting & broadcasting application state changes

A pluggable "Application State Gateway" that enforces the Event Sourcing Pattern for securely persisting & broadcasting application state changes

null 24 Apr 15, 2021
Apache RocketMQ go client

RocketMQ Client Go A product ready RocketMQ Client in pure go, which supports almost the full features of Apache RocketMQ, such as pub and sub message

The Apache Software Foundation 684 Jul 15, 2021
rpc/v2 support for JSON-RPC 2.0 Specification.

rpc rpc/v2 support for JSON-RPC 2.0 Specification. gorilla/rpc is a foundation for RPC over HTTP services, providing access to the exported methods of

High Performance, Kubernetes Native Object Storage 3 Jul 4, 2021
A protoc-gen-go wrapper including an RPC stub generator

// Copyright 2013 Google. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE fi

Kyle Lemons 35 May 13, 2020
webrpc is a schema-driven approach to writing backend services for modern Web apps and networks

webrpc is a schema-driven approach to writing backend servers for the Web. Write your server's api interface in a schema format of RIDL or JSON, and t

null 378 Jul 16, 2021
A pure Unix shell script implementing ACME client protocol

An ACME Shell script: acme.sh An ACME protocol client written purely in Shell (Unix shell) language. Full ACME protocol implementation. Support ACME v

acme.sh 22.9k Jul 24, 2021
The Go language implementation of gRPC. HTTP/2 based RPC

gRPC-Go The Go implementation of gRPC: A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information

grpc 14.1k Jul 23, 2021
Fast time-series data storage server accessible over gRPC

tstorage-server Persistent fast time-series data storage server accessible over gRPC. tstorage-server is lightweight local on-disk storage engine serv

Bartlomiej Mika 3 Jul 17, 2021
network multiplexing and framing protocol for RPC

TChannel Network multiplexing and framing protocol for RPC Read the Docs Languages: Node.js, Python, Go, Java Questions: Open a Github issue Uber's OS

Uber Open Source 1.1k Jul 13, 2021