| name | zhu327-perspective |
|---|---|
| description | zhu327 的工程哲学视角:非科班自学入行,从测试、Python 后端、腾讯 SRE 到 AI 工程化实践。 核心镜片包括:80%方案主义、Quick Start 主流程优先、领域模型优先、架构即约束、复利工程、Harness/Loop Engineering、问题驱动选型。 触发方式:用「zhu327视角」「如果是你怎么做架构」「这个方案怎么落地」等触发,或讨论技术选型、项目上手、代码可维护性、AI工程落地时自然切入。 注意:聚焦工程哲学与实践决策,不在一般语法/工具问题上自动触发。 |
基于源码分析,详细解读 Bifrost AI Gateway 的五大核心设计。所有行号引用基于当前 main 分支。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gevent.wsgi import WSGIServer | |
| from prometheus_client import multiprocess | |
| from prometheus_client import generate_latest, CollectorRegistry, CONTENT_TYPE_LATEST | |
| # Expose metrics. | |
| def app(environ, start_response): | |
| registry = CollectorRegistry() | |
| multiprocess.MultiProcessCollector(registry) | |
| data = generate_latest(registry) | |
| status = '200 OK' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (s *server) respond(w http.ResponseWriter, r *http.Request, data interface{}, status int) { | |
| w.WriteHeader(status) | |
| if data != nil { | |
| err := json.NewEncoder(w).Encode(data) | |
| s.logf("json encode %s", err) | |
| } | |
| } | |
| func (s *server) decode(w http.ResponseWriter, r *http.Request, v interface{}) error { | |
| return json.NewDecoder(r.Body).Decode(v) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package utils | |
| import ( | |
| "reflect" | |
| "unsafe" | |
| ) | |
| func BytesToString(b []byte) string { | |
| return *(*string)(unsafe.Pointer(&b)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -w %{time_connect}:%{time_starttransfer}:%{time_total} -X POST 'http://service-uri' -H 'Content-Type: application/json' --data 'post-data' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| wrk.path = "/rest/ping" | |
| wrk.method = "POST" | |
| wrk.body = "id=7579764573763278289&platformid=ANDROID&version=1.0.0" | |
| wrk.headers["Content-Type"] = "application/x-www-form-urlencoded" | |
| wrk.headers["deviceid"] = "354435052821931" | |
| wrk.headers["Accept"] = "application/json" | |
| logfile = io.open("wrk.log", "w"); | |
| local cnt = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| from tornado import gen | |
| from tornado import httpclient | |
| from tornado import httputil | |
| from tornado import ioloop | |
| from tornado import websocket | |
| import json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| from __future__ import print_function | |
| import re | |
| import sys | |
| filter = re.compile(r'site-packages/requests/.*') | |
| def tracer(frame, event, args): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| import argparse | |
| from gevent import monkey | |
| monkey.patch_socket() | |
| import logging | |
| logging.basicConfig(level=logging.DEBUG) |
NewerOlder