joe 2 năm trước cách đây
mục cha
commit
0c7d4f1678

+ 6 - 0
content/middleware/conan.md

@@ -0,0 +1,6 @@
+---
+title: "conan"
+date: 2023-08-05T16:11:48+07:00
+draft: true
+---
+

+ 6 - 0
content/middleware/conda.md

@@ -0,0 +1,6 @@
+---
+title: "conan"
+date: 2023-09-01T16:11:48+07:00
+draft: true
+---
+

+ 6 - 0
content/middleware/etcd.md

@@ -0,0 +1,6 @@
+---
+title: "etcd"
+date: 2023-10-14T16:11:48+07:00
+draft: true
+---
+

+ 1 - 1
content/middleware/meilisearch.md

@@ -1,7 +1,7 @@
 ---
 title: "Meilisearch"
 date: 2022-10-14T16:11:34+07:00
-draft: true
+draft: false
 ---
 
 # meilisearch 快速文檔

+ 298 - 0
content/middleware/nats.md

@@ -0,0 +1,298 @@
+---
+title: "Nats"
+date: 2023-07-26T13:11:48+07:00
+draft: false
+---
+
+# Nats Server 極速文檔
+
+描述版本
+nats server: 2.9.20
+nats: 0.0.35
+
+## 基於主題(Subject)的消息系統
+
+規則
+
+- 主題名稱最好使用 `[a-zA-Z0-9]` 構成的字符串。可以使用 `.` 來級聯名稱,起到 Subject 分組(Group)的效果
+- 主題名稱不可包含空格,其中 $ 開頭的為系統主題
+- `*, >` 用於訂閱(Subscribe)主題時作為 wildcard 使用。`*`匹配單詞,`>` 置於結尾匹配主題分組
+> `time.*.east` 匹配 time.us.east, time.eu.east
+> `time.us.>` 匹配 time.us.east, time.us.east.town, time.us.west
+> 可以使用多個 * 以及 >, eg. `*.*.east.>` 當前版本限制最多不超過 16 個
+
+## Core NATS 模式
+
+Core NATS 模式的消息系統不具備存儲功能
+
+- Publish-Subscribe
+> 一對多通信
+- Request-Reply
+> 請求-應答模式,基於 pub-sub 模式實現
+- Queue Groups
+> 一個 message 每次只有一個 subscriber 能夠受到
+
+## JetStream 模式
+
+###  術語
+- subject 也就是 Nats 模式下的主題
+- stream
+> stream 用於訂閱 subject,當創建 stream 時可指定訂閱的 subject(可多個),從此 pub 到該 subject
+> 的 message 都以 stream 的配置的策略存儲
+- consumer 用於客戶端消費 stream。作為 stream 的一個視圖(view),跟蹤客戶端的消費和確認進度
+> 分為 push/pull 兩種消息獲取方式
+> 可以是 ephemeral / durable 的
+
+###  stream 參數
+- Name: 不含空格 . * > 的普通字符串
+- Storage: File/Memory
+- Subjects: 主題列表, 主題支持 wildcard
+- Replicas: 每個消息在 cluster 模式下的份數, 最大為5
+- MaxAge: 任意消息的壽命 nanoseconds
+- MaxBytes: stream 的容量(體積)
+- MaxMsgs: stream 的容量(消息個數)
+- MaxMsgSize: 消息尺寸極限
+- MaxConsumers: 最多消費者個數
+- NoAck: stream 接收消息不確認
+- Retention:  LimitsPolicy/InterestPolicy/WorkQueuePolicy
+- Discard: DiscardOld / DiscardNew
+- Duplicates: 檢測重複消息的時間窗口 nanoseconds
+- Placement: 
+- Mirror: 指定本 stream 是其他 stream 的 mirror
+- Sources: 指定本 stream 的源 stream 列表
+- MaxMsgsPerSubject: 每個 subject 中最大消息數
+- Description: 描述
+- Sealed
+- DenyDelete: 禁止通過 API 刪除
+- DenyPurge: 禁止通過 API 清空
+- AllowRollup
+- RePublish: 消息存儲後立即發送到指定subject
+- AllowDirect
+- MirrorDirect
+- DiscardNewPerSubject
+
+###  consumer 參數
+- Durable: 設置後就為 durable 模式。不能使用空格 . * > /\ 符號,就普通字符串
+- FilterSubject:消費過濾器
+- AckPolicy: AckExplicit/AckNone/AckAll
+- AckWait: 服務傳遞消息到消費者後,如果在此時間內沒收到 ack,則重新傳遞
+- DeliverPolicy: stream 中接收消息的位置 DeliverAll / DeliverLast / DeliverNew / DeliverByStartSequence / DeliverByStartTime / DeliverLastPerSubject
+- OptStartSeq: 配合 DeliverByStartSequence 使用
+- OptStartTime: 配合 DeliverByStartTime
+- Description: 描述
+- InactiveThreshold: ephemeral 模式下,超出本設置無活動客戶端則清空 consumer
+- MaxAckPending: 未 ack 消息數量超出此值則停止傳遞
+- MaxDeliver: 未 ack 消息的最大傳遞次數
+- ReplayPolicy: ReplayOriginal / ReplayInstant
+- Replicas: 設置 consumer 狀態副本數。0表示從 stream 繼承設置
+- MemoryStorage: consumer state 保存在內存中
+- SampleFrequency: 為可觀察性設置的 ack 百分比 '30'/'30%'
+
+### KV存儲
+
+JetStream 是存儲層,然後才是服務於 stream 的存儲層,所以包含 KV 存儲很自然
+
+API
+
+- put
+- get
+- delete
+- purge
+- create
+- update
+- keys
+- watch
+- watch all
+- history
+
+設置
+
+- bucket 的最大尺寸
+- 單個值的最大尺寸
+- TTL 一個值能存儲多久(redis 的 expiration)
+
+
+## 啟動配置
+
+### 配置文件格式
+
+- 格式為 JSON/YAML,JSON 鍵不需要引號,可以帶注釋(//或#)。utf8編碼
+- 值支持 字符串,數字,list, map。1K=1000, 1KB=1024。
+- 可以用 `$` 使用變量, 變量可以是環境變量
+- 可以 `include` 其他配置文件
+- nats-server -c server.conf
+
+### 子配置
+
+- Tls
+	- cert_file
+	- key_file
+	- ca_file
+	- cipher_suites
+	- curve_preferences
+	- insecure: NOT recommend
+	- verify
+	- verify_and_map
+	- verify_cert_and_check_known_urls
+	- pinned_certs
+	- timeout
+- User
+	- user: string
+	- password: string
+	- nkey: string
+	- permissions: map
+- Authorization
+	- token
+	- user
+	- password
+	- users: [User]
+	- timeout
+
+### 配置項
+
+- host: 0.0.0.0
+- port: 4222
+- listen: <host>:<port>
+- client_advertise: 通告客戶端連接的 cluster 地址, host:port 格式
+- tls: Tls
+- ### profiling
+- prof_port: 6543
+- ### log
+- debug: false
+- trace: true
+- logtime: false
+- logfile_size_limit: 1G
+- log_file: "/tmp/nats-server.log"
+- gateway
+	- name
+	- reject_unknown_cluster
+	- gateways: [gateway]
+		- name
+		- url
+		- urls [url]
+		- tls:Tls
+	- host
+	- port
+	- listen
+	- tls
+	- advertise
+	- connect_retries
+	- authorization: Authorization
+- leafnodes
+	- host
+	- port
+	- listen
+	- tls: Tls
+	- advertise
+	- no_advertise
+	- authorization: Authorization
+	- remotes: []
+		- url
+		- urls
+		- account: Account
+		- credentials
+		- tls
+		- ws_compression
+		- ws_no_masking
+	- reconnect
+	- authorization
+		- user
+		- password
+		- account: Account
+		- timeout
+		- users: [user]
+			- user
+			- password
+			- account: Account
+- cluster
+	- host
+	- port
+	- name
+	- listen
+	- tls: Tls
+	- advertise/cluster_advertise
+	- no_advertise
+	- routes: [url]
+	- connect_retries
+	- authorization: Authorization
+- ### timeouts
+- ping_interval: "2m"
+- ping_max: 2
+- write_deadline: "10s"
+- ### limites
+- max_connections: '64k'
+- max_control_line: 4KB
+- max_payload
+- max_pending
+- max_subscriptions
+- jetstream:
+	- store_dir
+	- max_mem
+	- max_file
+	- max_memory_store
+	- max_file_store
+	- cipher
+	- key
+	- max_outstanding_catchup
+- ### centralized auth
+- authorization
+- accounts
+- no_auth_user
+- ### decentralized auth
+- operator
+- resolver
+- resolver_tls
+- resolver_preload
+- ### runtime
+- disable_sublist_cache
+- lame_duck_duration
+- lame_duck_grace_period
+- ### monitor
+- server_name
+- server_tags
+- trace
+- trace_verbose
+- debug
+- logtime
+- log_file
+- log_size_limit
+- max_traced_msg_len
+- syslog
+- remote_syslog
+- http_port
+- http
+- https_port
+- http_base_path
+- https
+- system_account
+- pid_file
+- port_file_dir
+- connect_error_reports
+- reconnect_error_reports
+- ### mqtt
+- mqtt
+	- host
+	- port
+	- listen
+	- tls: Tls
+	- authorization: Authorization
+	- act_wait: "1m"
+	- max_ack_pending: 100
+- websocket
+	- host
+	- port
+	- advertise
+	- tls: Tls
+	- no_tls: true
+	- same_origin: true
+	- allowed_origins: [url]
+	- compression: true
+	- handshake_timeout: "2s"
+	- jwt_cookie: 'my_jwt_cookie_name'
+	- no_auth_user: ""
+	- authorization: Authorization
+
+### Config file reload
+```shell
+nats-server --signal reload
+```

+ 81 - 0
content/middleware/pitaya_api_doc.md

@@ -0,0 +1,81 @@
+---
+title: "pitaya API doc"
+date: 2023-08-02T16:11:48+07:00
+draft: true
+---
+
+# pitaya API 文檔
+
+從源代碼整理,基於 pitaya v2.6.1。和[官方文檔](https://pitaya.readthedocs.io/en/latest/index.html)不衝突
+
+## pitaya 根空間(全局)
+
+func NewTimer(interval time.Duration, fn timer.Func) *timer.Timer
+func NewCountTimer(interval time.Duration, count int, fn timer.Func) *timer.Timer
+func NewAfterTimer(duration time.Duration, fn timer.Func) *timer.Timer 
+func NewCondTimer(condition timer.Condition, fn timer.Func) (*timer.Timer, error) 
+func SetTimerPrecision(precision time.Duration) 
+func SetTimerBacklog(c int)
+
+func Configure(isFrontend bool, serverType string, serverMode ServerMode, serverMetadata map[string]string, cfgs ...*viper.Viper)
+func GetDieChan() chan bool 
+func SetDebug(debug bool) 
+func SetHeartbeatTime(interval time.Duration)
+func GetServerID() string 
+func GetMetricsReporters() []metrics.Reporter 
+func GetServer() *cluster.Server 
+func GetServerByID(id string) (*cluster.Server, error) 
+func GetServersByType(t string) (map[string]*cluster.Server, error) 
+func GetServers() []*cluster.Server 
+func GetSessionFromCtx(ctx context.Context) session.Session 
+func Start() 
+func SetDictionary(dict map[string]uint16) error 
+func AddRoute(serverType string, routingFunction router.RoutingFunc) error 
+func Shutdown() 
+func StartWorker() 
+func RegisterRPCJob(rpcJob worker.RPCJob) error 
+func Documentation(getPtrNames bool) (map[string]interface{}, error) 
+func IsRunning() bool 
+func RPC(ctx context.Context, routeStr string, reply proto.Message, arg proto.Message) error 
+func RPCTo(ctx context.Context, serverID, routeStr string, reply proto.Message, arg proto.Message) error 
+func ReliableRPC(routeStr string, metadata map[string]interface{}, reply, arg proto.Message) (jid string, err error) 
+func ReliableRPCWithOptions(routeStr string, metadata map[string]interface{}, reply, arg proto.Message, opts *config.EnqueueOpts) (jidstring, err error) 
+func SendPushToUsers(route string, v interface{}, uids []string, frontendType string) ([]string, error) 
+func SendKickToUsers(uids []string, frontendType string) ([]string, error) 
+func GroupCreate(ctx context.Context, groupName string) error 
+func GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error 
+func GroupMembers(ctx context.Context, groupName string) ([]string, error) 
+func GroupBroadcast(ctx context.Context, frontendType, groupName, route string, v interface{}) error 
+func GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) 
+func GroupAddMember(ctx context.Context, groupName, uid string) error 
+func GroupRemoveMember(ctx context.Context, groupName, uid string) error 
+func GroupRemoveAll(ctx context.Context, groupName string) error 
+func GroupCountMembers(ctx context.Context, groupName string) (int, error) 
+func GroupRenewTTL(ctx context.Context, groupName string) error 
+func GroupDelete(ctx context.Context, groupName string) error 
+func Register(c component.Component, options ...component.Option) 
+func RegisterRemote(c component.Component, options ...component.Option) 
+func RegisterModule(module interfaces.Module, name string) error 
+func RegisterModuleAfter(module interfaces.Module, name string) error 
+func RegisterModuleBefore(module interfaces.Module, name string) error 
+func GetModule(name string) (interfaces.Module, error) 
+func NewApp(
+	serverMode ServerMode,
+	serializer serialize.Serializer,
+	acceptors []acceptor.Acceptor,
+	dieChan chan bool,
+	router *router.Router,
+	server *cluster.Server,
+	rpcClient cluster.RPCClient,
+	rpcServer cluster.RPCServer,
+	worker *worker.Worker,
+	serviceDiscovery cluster.ServiceDiscovery,
+	remoteService *service.RemoteService,
+	handlerService *service.HandlerService,
+	groups groups.GroupService,
+	sessionPool session.SessionPool,
+	metricsReporters []metrics.Reporter,
+	config config.PitayaConfig,
+) *App
+
+## app

+ 12 - 0
content/posts/git-in-real-world.md

@@ -39,6 +39,12 @@ $git config --global core.autocrlf true
 $git config --global core.whitespace cr-at-eol
 ```
 
+### Setup editor
+
+```shell
+$git config --global core.editor vim
+```
+
 ## git log
 
 ### 查看指定文件修改历史
@@ -101,6 +107,12 @@ $git rebase upstream/master
 $git push -f origin master
 ```
 
+### 撤銷修改(未 add)
+
+```shell
+$git checkout -- .
+```
+
 ### remove untracked files
 
 ```shell

+ 8 - 1
content/res/docs_or_books.md

@@ -44,4 +44,11 @@ draft: false
 - [How to Design Programs, Second Edition](https://htdp.org/2022-6-7/Book/index.html)
 - [Structure and Interpretation of Computer Programs](https://mitpress.mit.edu/sites/default/files/sicp/index.html)
 
-- [Dex: OpenID Service](https://dexidp.io/docs/getting-started/)
+- [Dex: OpenID Service](https://dexidp.io/docs/getting-started/)
+- [pion](https://pion.ly)
+> webrtc 代碼,書籍
+- [webrtc-web](https://codelabs.developers.google.com/codelabs/webrtc-web/#0)
+> Real time communication with WebRTC
+
+- [Build your own Lisp](https://buildyourownlisp.com/)
+> using C

+ 21 - 2
content/res/github_projects.md

@@ -77,6 +77,8 @@ draft: false
 > A scalable, distributed, collaborative, document-graph database, for the realtime web
 - [webview](https://github.com/webview/webview)
 > Tiny cross-platform webview library for C/C++/Golang. Uses WebKit (Gtk/Cocoa) and Edge (Windows)
+- [luvit](https://github.com/luvit/luvit)
+> Lua + libuv + jit
 
 ### Golang
 
@@ -104,6 +106,18 @@ draft: false
 > Scalable real-time messaging server in a language-agnostic way. Set up once and forever.
 - [chromedp](https://github.com/chromedp/chromedp)
 > A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.
+- [gophish](https://github.com/gophish/gophish)
+> Open-Source Phishing Toolkit
+- [fyne](https://github.com/fyne-io/fyne)
+> Cross platform GUI toolkit in Go inspired by Material Design
+- [vuls](https://github.com/future-architect/vuls)
+> Agent-less vulnerability scanner for Linux, FreeBSD, Container, WordPress, Programming language libraries, Network devices
+- [dragonboat](https://github.com/lni/dragonboat)
+> A feature complete and high performance multi-group Raft library in Go.
+- [hashicorp/raft](https://github.com/hashicorp/raft)
+> Golang implementation of the Raft consensus protocol
+- [pebble](https://github.com/cockroachdb/pebble)
+> RocksDB/LevelDB inspired key-value database in Go
 
 ### Python
 
@@ -139,9 +153,14 @@ draft: false
 - [solidjs](https://www.solidjs.com/)
 - [daisyui](https://daisyui.com/)
 > he most popular, free and open-source Tailwind CSS component library
-=======
 - [react-native-skia](https://shopify.github.io/react-native-skia)
->>>>>>> Stashed changes
+- [docusaurus](https://github.com/facebook/docusaurus)
+> Easy to maintain open source documentation websites.
+> 原來近來(2023)流行的文檔格式都是用這個做的
+- [react-dnd](https://react-dnd.github.io/react-dnd/about)
+> 游戏类的 dnd 库
+- [dndkit](https://docs.dndkit.com/)
+> 支持控件拖动
 
 ### Rust
 

+ 8 - 1
content/res/languages.md

@@ -13,4 +13,11 @@ draft: false
 - [mruby](https://mruby.org/)
 - [rubyonrails](https://rubyonrails.org/)
 - [assemblyscript](https://www.assemblyscript.org)
-- [pike](https://pike.lysator.liu.se/)
+- [pike](https://pike.lysator.liu.se/)
+- [nelua](https://github.com/edubart/nelua-lang)
+- [zig](https://github.com/ziglang/zig)
+> 更好的C
+- [bog](https://github.com/Vexu/bog)
+> zig 实现的一个强类型脚本语言
+- [mojo](https://www.modular.com/mojo)
+> For all AI developers

+ 9 - 1
content/res/tools.md

@@ -16,4 +16,12 @@ draft: false
 - [crontab.guru](https://crontab.guru)
 - [VPS](https://virmach.com/)
 - [隨機聽歌曲](https://www.locserendipity.com/PushPlay.html)
-- [Email server toolpage](https://mxtoolbox.com/)
+- [Email server toolpage](https://mxtoolbox.com/)
+- [tabserve](https://tabserve.dev/)
+> 代理 HTTPS 域名 到 localhost:port
+- [frp](https://github.com/fatedier/frp)
+> A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
+- [nps](https://github.com/ehang-io/nps)
+> 一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等等……,并带有功能强大的web管理端。
+- [gost](https://github.com/ginuerzh/gost)
+> GO Simple Tunnel - a simple tunnel written in golang