适用硬件:TN3399 v3(Rockchip RK3399,2×Cortex-A72 + 4×Cortex-A53) 适用场景:PhotoPrism 的视频转码(把非 AVC 视频转成浏览器可播的 H.264/AVC sidecar) 内核约束:不更换内核,使用板子出厂自带的 legacy 4.4 BSP 内核
基于源码分析,详细解读 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 |
NewerOlder