Go Engineering - Specification - Workflow
集中式 在本地仓库的 master 分支开发,将修改后的代码 commit 到远程仓库,如有冲突先本地解决再提交 适合场景:团队人员少、开发不频繁、不需要同时维护多个版本的小项目 功能分支 12345678910# git checkout -b feature/rate-limiting# git add limit.go# git commit -m "add rate limiting"# git push origin feature/rate-limiting# Github: Compare & pull request -> Create pull request# Github: Code Review -> Merge pull request Merge PR Create a merge commit – 推荐 底层操作:git merge --no-ff With --no-ff, create a merge commit in all cases, even when the merge could instead be...
Go Engineering - Specification - Directory
平铺式 主要用在 Go 包(框架、库)中,相对来说比较简单,如 glog 12# lsLICENSE README.md glog.go glog_file.go glog_test.go go.mod 结构化 主要用在 Go 应用中,相对来说比较复杂,事实规范:project-layout 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485├── api│ ├── openapi│ └── swagger├── build│ ├── ci│ ├── docker│ │ ├── iam-apiserver│ │ ├── iam-authz-server│ │ └── iam-pump│ ├── package├── CHANGELOG├── cmd│ ├...
Infrastructure - Authentication - LDAP
What is LDAP 目录服务 目录 ≈ 树状结构的数据库 目录服务 ≈ 以树状结构的目录数据库为基础,外加各种访问协议的信息查询服务 目录数据库 vs 关系型数据库:读取性能极高,写入性能非常差(不支持事务),不适合频繁修改数据 用途:具有层次性且不需要频繁修改的数据,例如企业员工信息、企业设备信息等 LDAP DAP = Directory Access Protocol X.500 是一套目录服务的标准(协议族) 通过 X.500 可以将局部的目录服务连接起来,构建基于 Internet 的分布在全球的目录服务系统 DAP 是 X.500 的核心组成之一,但非常复杂,因此诞生了 LDAP LDAP 是基于 X.500 的 DAP 发展而来,目前是第 3 版 LDAP 特点 基于 TCP/IP 以树状结构存储数据 读取速度快,写入速度慢 服务端用于存放数据,客户端用于操作数据 跨平台,维护简单 支持 SSL/TLS 加密 协议是开放的 样例
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...















