摘要: mutex 流程 type Mutex struct { state int32 sema uint32 } 等效于 type Mutex struct { locked uint woken uint starving uint waiterCount uint sema uint32 } Loc 阅读全文
posted @ 2024-06-24 09:39 Aloe_n 阅读(1) 评论(0) 推荐(0) 编辑
摘要: WaitGroup流程 type WaitGroup struct { noCopy noCopy // 64-bit value: high 32 bits are counter, low 32 bits are waiter count. // 64-bit atomic operations 阅读全文
posted @ 2024-06-24 09:37 Aloe_n 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 优雅关闭 channel 不使用select, 不借助额外channel. package main import ( "fmt" "sync" ) func main() { data_c := make(chan string, 10) // producer group go func() { 阅读全文
posted @ 2024-06-18 10:18 Aloe_n 阅读(2) 评论(0) 推荐(0) 编辑
摘要: Cannot assign requested address 问题排查 背景 工单服务调用了我提供的自动化接口, 但是显示调用失败, 失败原因: Cannot assign requested address. 排查过程 根据提示猜测是端口用尽. 登录机器查看: >>> netstat -nap 阅读全文
posted @ 2024-06-12 16:07 Aloe_n 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 任务下发优化分析过程记录 背景 最近接手了一个任务下发平台, 基本功能是接收任务脚本, 下发给目标服务器执行. 简化的业务流程如下: sequenceDiagram autonumber participant client participant server participant DB par 阅读全文
posted @ 2024-06-11 17:47 Aloe_n 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 从字节码的角度看 python 变量交换 背景 从一道算法题开始: 反转链表 class ListNode: def __init__(self, v) -> None: self.val = v self.next = None def add_next(self, v): new_node = 阅读全文
posted @ 2024-03-28 18:25 Aloe_n 阅读(7) 评论(0) 推荐(0) 编辑
摘要: python3.6 使用调用栈储存上下文变量 从 python3.7 开始, 新增 contextvars 模块, 用于储存上下文变量. 使用场景 # python3.7 from contextvars import ContextVar import asyncio user = Context 阅读全文
posted @ 2024-03-25 11:54 Aloe_n 阅读(8) 评论(0) 推荐(0) 编辑
摘要: python 服务自动生成 js 调用 原理 接管请求分发过程; 为每个 command 维护对应的 handler; 利用 python 动态特性, 获得 handler 的参数; 利用模版生成 js 代码; 利用**kwargs 获取所有参数传递给 handler; Demo 以 Flask 为 阅读全文
posted @ 2024-03-18 11:35 Aloe_n 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 多层负载均衡架构 flowchart LR c1 c2 c3 c4 subgraph 四层负载均衡 lb1 lb2 end subgraph 七层负载均衡 ngx1 ngx2 ngx3 ngx4 end subgraph 后端服务 rs1 rs2 rs3 rs4 end c1--DNS-->lb1 阅读全文
posted @ 2024-03-16 21:53 Aloe_n 阅读(4) 评论(0) 推荐(0) 编辑
摘要: mysql死锁排查案例 行锁的兼容矩阵 / Gap Insert Intention Record Next-Key Gap 兼容 兼容 兼容 兼容 Insert Intention 冲突 兼容 兼容 冲突 Record 兼容 兼容 冲突 冲突 Next-Key 兼容 兼容 冲突 冲突 问题描述 业 阅读全文
posted @ 2024-03-15 17:54 Aloe_n 阅读(8) 评论(0) 推荐(0) 编辑