Skip to content

Instantly share code, notes, and snippets.

@yeaha
yeaha / team_maker.go
Last active July 15, 2024 12:58
玩家匹配
package example
import (
"context"
"errors"
"sync/atomic"
"time"
"github.com/joyparty/gokit"
)
@yeaha
yeaha / call_grpc.go
Created November 13, 2023 08:47
不通过grpc stub,直接发起grpc请求
package main
import (
"context"
"flag"
"fmt"
"log"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
@yeaha
yeaha / httperror.js
Created July 29, 2013 09:52
自定义javascript Error类
var http = require('http');
// Http错误
function HttpError(code, msg) {
Error.captureStackTrace(this, arguments.callee);
this.name = arguments.callee.name;
var status = http.STATUS_CODES;
if (!code || !(code in status))
@yeaha
yeaha / promisedQuery.js
Last active December 20, 2015 00:49
把any-db的查询用Q封装为promise风格
var _ = require('underscore');
var Q = require('q');
var pool = require('any-db').createPool('postgres://dev:[email protected]/lysine', {name: 'test', min: 3, max: 10, log: true});
function query(sql, params) {
return _query(sql, params, false);
}
function stream_query(sql, params) {
@yeaha
yeaha / storage_pool_example.php
Last active April 9, 2021 07:45
Lysine存储服务水平/垂直切分机制样例
<?php
// 一个一致性hash实现 http://github.com/pda/flexihash
require '/path/to/flexihash/include/init.php';
require '/path/to/lysine/loader.php';
// user和topic数据垂直切分
// user数据放在mysql数据库
// topic数据放在postgresql数据库
// topic数据水平切分,分区到3台服务器上
$config = array(