Infrastructure - Authentication - Basic + JWT
HTTP Authentication Some common authentication schemes include: Basic Bearer The server responds to a client with a 401 (Unauthorized) response status and provides information on how to authorize with a WWW-Authenticate response header containing at least one challenge. A client that wants to authenticate itself with the server can then do so by including an Authorization request header with the credentials. Usually a client will present a password prompt to the user and will then issue the request inc...
Infrastructure - Authentication - Scheme
ConceptSecrets and Keys Authentication is the art of unlocking things with a secret. At the heart of every authentication is a shared secret! The secret has two copies. One copy is with the system and the other copy is with you. Your copy is what is called the private key. The server only has a highly encrypted version of the secret; it doesn’t know what the decrypted value would look like. That’s why if you forget your password, you’d need to reset it. Public and Private Keys Your copy which is th...
Go Engineering - Specification - Commit
规范化的优势 优势:Commit Message 可读性更好 + 自动化 清晰地知道每个 Commit 的变更内容 基于 Commit Message 进行过滤查找:git log --oneline --grep "^feat|^fix|^perf" 基于 Commit Message 生成 Change Log 基于 Commit Message 触发 CICD 流程 确定语义化版本的版本号 fix 类型映射为 PATCH 版本 feat 类型映射为 MINOR 版本 带有 BREAKING CHANGE 的 Commit 映射为 MAJOR 版本 Angular 规范 Angular 格式清晰,使用最为广泛;Angular 规范是一种语义化的提交规范 Commit Message 是语义化的 Commit Message 都会被归为一个有意义的类型,用来说明本次 Commit 的类型 Commit Message 是规范化的 Commit Message 遵循预先定义好的规范,可以被开发者和工具识别 样例 规范 Commit Message 组成部分:...
Go Engineering - Specification - Open Source + Document + Version
规范 分类 规范 非编码类规范 开源规范 文档规范 版本规范 提交规范 发布规范 编码类规范 目录规范 代码规范 接口规范 日志规范 错误码规范 开源规范开源协议 Apache 是对商业应用友好的协议,大公司的开源项目通常会采用 Apache 2.0 开源协议 开源项目 较高的单元覆盖率 代码库中不能包含敏感信息 及时处理 PR、ISSUE 等 持续更新和 Bug Fix 文档规范 文档属于软件交付的一个重要组成部分 README12345678910111213141516171819202122# 项目名称## 功能特性## 软件架构(可选)## 快速开始### 依赖检查### 构建### 运行## 使用指南## 如何贡献## 社区(可选)## 关于作者## 谁在用(可选)## 许可证 项目文档12345678910111213141516171819202122232425262728docs├── devel # 开发文档,可以提前规划好,英文版文档和中文版文档│...
Go Engineering - IAM
概述 IAM:Identity and Access Management 用途:在特定条件下,用户能够对哪些资源做哪些操作 工作流程 3 种平台资源:User、Secret、Policy 系统架构 核心功能 创建平台资源 用户通过 iam-webconsole 或者 iamctl 请求 iam-apiserver,完成 User、Secret、Policy 的 CRUD iam-apiserver 将这些资源持久化到 MySQL 中 请求 API 完成资源授权 用户通过 iam-authz-server 的 /v1/authz 接口进行资源授权 请求 /v1/authz 接口需要通过密钥认证,认证通过后会查询授权策略,从而决定资源是否被允许 为了提高 /v1/authz 接口的性能,iam-authz-server 将密钥和策略缓存在内存中 iam-authz-server 通过 gRPC 调用 iam-apiserver,将密钥和策略缓存到内存中 为了保证数据的一致性,借助 Redis Channel 当 iam-ap...
Docker Foundation - Union FS
Union FS Docker 的创新在文件系统:通过镜像解决容器分发的问题 将不同目录挂载到同一个虚拟文件系统下的文件系统 支持为每一个成员目录(类似于 Git Branch)设定权限:readonly、readwrite、whiteout-able 文件系统分层,对 readonly 权限的 Branch 可以逻辑上进行修改(增量、不影响 readonly 部分) 用途 将多个 Disk 挂在同一个目录下 将一个 readonly 的 Branch 和一个 writeable 的 Branch 联合在一起 Docker 镜像 层可以复用,增量分发 12# docker image inspect --format '{{.RootFS}}' centos:latest{layers [sha256:74ddd0ec08fa43d09f32636ba91a0a3053b02cb4627c35051aff89f853606b59] } 镜像文件系统 bootfs Bootloader 引导加载 kerne...
Docker Foundation - Namespace + Cgroup
概要 基于 Linux Kernel 的 Cgroup、Namespace、Union FS 等技术,对进程进行封装隔离,属于 OS 层面的虚拟化技术 由于被隔离的进程独立于宿主机和其它被隔离的进程,因此称为容器 演变历史 最早基于 LXC – a linux container runtime 0.7:去除 LXC,转而使用自研的 Libcontainer 1.11:使用 runC 和 containerd Docker 在容器的基础上,进行了进一步的封装,极大地简化了容器的创建和维护 Docker vs VM Docker Engine 是一个 Daemon 进程,启动一个容器的时候,相当于执行了一次进程的 Fork 操作 Container VM 启动时间 秒级 分钟级 硬盘使用 MB 级别 GB 级别 性能 接近原生 弱于 单机支持量 上千 几十 容器标准 OCI – Open Container Initiative K8S 的主要贡献:标准化 后期 Docker 公司不得不让步,兼容 OCI 标准 核心规范:Image + Runti...
ASM - Introduction
Glance ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify existing classes or to dynamically generate classes, directly in binary form. ASM provides some common bytecode transformations and analysis algorithms from which custom complex transformations and code analysis tools can be built. ASM offers similar functionality as other Java bytecode frameworks, but is focused on performance. Because it was designed and implemented to be as small and as fast as p...
Cloud Native Foundation - Go Engineering
IO 模型 阻塞:等待数据报文就绪;同步:等待内核拷贝数据 阻塞 + 同步 非阻塞 + 同步轮询 轮询不是一个好的检查状态变更的方式,很难支撑高并发的场景 IO 多路复用 Go select channel 也是借鉴于此 select / poll 在用户态将关心的 fd 列表(限制为 1024)发送给 kernel epoll 不需要传递 fd 列表:通过 mmap,将用户态和内核态的内存共享 事件驱动 epoll_create:初始化 wq(wait queue)、rdlist(ready list)、rbr(red-black root) epoll_ctl:一个 socket 创建后会加入到红黑树进行管理 epoll_wait:当 socket 尚未就绪时,用户线程会阻塞 当收到数据报文后,触发中断处理程序 然后将对应的 epitem(对应一个 socket)移动到 rdlist,并且唤醒阻塞在该 socket 上的用户进程 支持高并发 非阻塞 + 异步 HTTP G 与 socket fd 绑定 当 socket fd 尚未就绪时,将对应的 G 设置为 ...
Cloud Native Foundation - Go Memory Management
堆内存管理Linux 进程 管理过程 Allocator 的职责:通过系统调用向 OS 申请内存(MB/GB);响应 Mutator(即应用) 的内存申请(KB) Collector:交还给 Allocator,再由 Allocator 决定是否释放并归还给 OS 初始化连续内存块为堆 在内存申请的时候,Allocator 从堆内存的未分配区域分割小内存块 用链表将已分配内存连接起来 需要信息描述每个内存块的元数据(对象头):大小、是否使用、下一个内存块的地址 Example: Ruby allocates memory from the memory allocator, which in turn allocates from the kernel 面临挑战 内存分配需要系统调用,在频繁分配内存的时候,系统性能较低 C 的每次 malloc 是需要系统调用的 Java 的 Allocator 可以直接一次性申请大内存,然后在用户态再慢慢分配 多线程共享相同的内存空间,同时申请内存,需要加锁,或者采用类似 JVM 中的 TLAB 来缓解竞争 经过不断地内存分配和回收,...















