新 RPC 服务器采用自定义文本协议,并满足以下条件:
- 可以在各种语言中简单的实现
- 能被快速解析
- 方便 Telnet 调试
相对于二进制协议,新 RPC 服务器的文本协议议具有较高的可读性,也容易被实现, 减少在客户端实现中出现BUG,并且解析性可以做到与二进制协议接近。
type InitFunction func() (interface{}, error) | |
type ConnectionPoolWrapper struct { | |
size int | |
pool chan interface{} | |
} | |
/** | |
Call the init function size times. If the init function fails during any call, then | |
the creation of the pool is considered a failure. |
#!/bin/bash | |
while [ ! -d .hg ]; do | |
cd .. | |
[ -f proc/cpuinfo ] && break | |
done | |
[ ! -d .hg ] && echo 'Oops! No hg repository found.' && exit | |
for f in `hg st | awk '{print $2}'`; do |
package main | |
import ( | |
"net" | |
"io" | |
"log" | |
) | |
func main() { | |
l, err := net.Listen("tcp", "127.0.0.1:9999") |
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"io" | |
"bufio" | |
"runtime" | |
"path/filepath" |
package main | |
import ( | |
"fmt" | |
"strings" | |
"database/sql" | |
) | |
const ( | |
SQL_INSERT = "INSERT INTO %s (%s) VALUES (%s)" |
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"regexp" | |
"strings" | |
) |
package main | |
import ( | |
"fmt" | |
"time" | |
"sync/atomic" | |
) | |
const ( | |
ITEM_DATA_SIZE = 4096 |
#!/bin/bash | |
#.git/hooks/pre-commit | |
EXEC=`php -r "echo 'php ', implode(DIRECTORY_SEPARATOR, [__DIR__, 'vendor', 'bin', 'phpcs']);"` | |
FILES=`git diff --cached --name-only | grep -i php$ | grep ^app` | |
ARGS='--standard=psr2 --encoding=utf8 -p' | |
for fn in $FILES; do | |
if [ ! -f $fn ]; then | |
DELETE=($fn) |