锘??xml version="1.0" encoding="utf-8" standalone="yes"?>C++鍗氬-閲戝簡鐨勪笓鏍?/title><link>http://www.2676208.com/jinq0123/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 25 Aug 2019 09:22:16 GMT</lastBuildDate><pubDate>Sun, 25 Aug 2019 09:22:16 GMT</pubDate><ttl>60</ttl><item><title>golang net Windows 杩樹笉鏀寔鑷畾涔塪nshttp://www.2676208.com/jinq0123/archive/2019/04/20/216361.html閲戝簡閲戝簡Sat, 20 Apr 2019 02:52:00 GMThttp://www.2676208.com/jinq0123/archive/2019/04/20/216361.htmlhttp://www.2676208.com/jinq0123/comments/216361.htmlhttp://www.2676208.com/jinq0123/archive/2019/04/20/216361.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/216361.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/216361.html
(閲戝簡鐨勪笓鏍?2019.4)

See: https://github.com/golang/go/issues/29621

浣跨敤 consul 娉ㄥ唽鏈嶅姟锛屽彲浣跨敤 consul 鐨?DNS 瑙f瀽鍒?#37832;嶅姟鐨?#37734;板潃銆?br />浣嗘槸 golang 鐩?#37714;?1.12 浠嶇劧鍦?Windows 涓婃棤娉?#28003;跨敤鑷畾涔?#37928;?DNS 鏈嶅姟锛屽苟涓旀病鏈夎鍒?#37824;寔銆?br />
渚嬪鏈?#37832;?127.0.0.1 寮 consul, 娉ㄥ唽 myservice:8888 鏈嶅姟銆?br />consul DNS 鐨勯粯璁?#32468;?#37721;?#28051;?8600.

grpc 鐨?Dial() 鍏?#29825;?#26440;?#37711;?#28051;涓?dns 鍦板潃锛?#28000;?#28051;?grpc.Dial() 鍦?Linux 鏈?#28051;婃垚鍔?#38171;?#28003;?#37734;?Windows 涓婂け璐?#38171;?br />
conn, err := grpc.Dial("dns://127.0.0.1:8600/myservice.service.consul:8888", ...)


閲戝簡 2019-04-20 10:52 鍙戣〃璇?#29825;?/a>
]]>
?#25956;璧嬪?#28000;?#37831;?protobuf CopyFrom()http://www.2676208.com/jinq0123/archive/2019/04/04/216338.html閲戝簡閲戝簡Thu, 04 Apr 2019 09:57:00 GMThttp://www.2676208.com/jinq0123/archive/2019/04/04/216338.htmlhttp://www.2676208.com/jinq0123/comments/216338.htmlhttp://www.2676208.com/jinq0123/archive/2019/04/04/216338.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/216338.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/216338.html
绀?#28186;?#38171;歔Replace protobuf CopyFrom with assignment](https://github.com/tensorflow/tensorflow/commit/9501c4104125fb8c2c2d2e837fc2dd8a24034d52)

protobuf 鐢?#37812;?#37928;?C++ 浠g爜涓?#38171;屽洜涓?CopyFrom() ?#24434;浠?#37818;?#37721;?#28000;?#28003;?Message 浣?#28051;?#37721;傛暟锛?br />鎵浠?#37832;夊彲?#20824;鍦?涓笉鍚岀被鍨?#37928;?#23057;堟伅涔嬮?#26449;?#23941;埗銆?br />
```
  void CopyFrom(const ::google::protobuf::Message& from) final;
  void CopyFrom(const PlayerData& from);
```

鑰岃?#23338;兼搷浣滃彲浠ヤ繚璇佺被鍨嬫纭?#37510;?br />
```
class PlayerData : public ::google::protobuf::Message {
 public:
  ...
  inline PlayerData& operator=(const PlayerData& from) {
    CopyFrom(from);
    return *this;
  }
  #if LANG_CXX11
  inline PlayerData& operator=(PlayerData&& from) noexcept {
    ...
  }
  #endif
```

?#34987;鍨嬩笉涓鑷存椂缂?#29831;戜細?#23012;閿?#38171;?br />```
error: no match for ‘operator=’ (operand types are ‘a::PlayerData’ and ‘a::HeroInfo’)
```

鍙戠幇鑷繁?#25956;?#31777;澶氬勾鐨?CopyFrom() ?#20824;?#27128;閿?#29831;?#37928;勪?#36328;敤銆?img src ="http://www.2676208.com/jinq0123/aggbug/216338.html" width = "1" height = "1" />

閲戝簡 2019-04-04 17:57 鍙戣〃璇?#29825;?/a>
]]>open-match鍖归厤娴佺▼http://www.2676208.com/jinq0123/archive/2019/01/31/216228.html閲戝簡閲戝簡Thu, 31 Jan 2019 02:21:00 GMThttp://www.2676208.com/jinq0123/archive/2019/01/31/216228.htmlhttp://www.2676208.com/jinq0123/comments/216228.htmlhttp://www.2676208.com/jinq0123/archive/2019/01/31/216228.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/216228.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/216228.html

# open-match鍖归厤娴佺▼


(閲戝簡鐨勪笓鏍?2019.1)

https://github.com/GoogleCloudPlatform/open-match

open-match ?#27128;涓涓?#38315;氱敤鐨勬父鎴?#37718;归厤妗嗘灦銆?br />鐢辨父鎴忔彁渚?#38007;畾涔?#37928;?#37718;归?#23943;畻娉?#38171;?#28000;ocker闀滃儚鐨勬柟寮忔彁渚?#38171;?#37510;?br />
鍒?#28051;?#28598;?#28051;?#26473;涚▼锛屽悇杩涚▼涔嬮?#26449;?#21464;韩涓涓?redis.

* 鍓嶇, 鎺?#37824;?#37916;?#28729;?#37716;?#37711;?redis锛?#37812;?#37716;?#37722;?#38315;氱煡鐜?#28729;?#37812;块棿鏈嶅?#26495;潃
* 鍚庣锛?#29825;?#32515;?#28051;灞?#29238;鎴?#37928;?#37718;归厤瑙?#37714;?#38171;?#29825;?#32515;?#37812;块棿鏈嶅?#26495;潃
* MMFOrc锛屽惎鍔?#37718;归?#23943;畻娉?MMF)
* MMF, 鑷畾涔?#37718;归?#23943;畻娉?#38171;?#29831;?#37721;?redis 鑾?#37721;?#37916;?#28729;?#38171;屽?#24402;厤鎴?#37716;熷氨灏嗙粨鏋滃啓鍏?redis. 浠?#37718;归厤涓灞?#27688;閫鍑?#37510;?br />
?#29238;鎴?#37832;?#28051;?#26473;?#37818;?open-match 鐨勫?#23943;涓?#37722;庣鐨?#26473;涚▼锛屽垎鍒?#32457;?#28051;?frontendclient 鍜?Director銆?br />杈?#37711;?#37714;?閮?#28000;?#38171;?#28051;?#27128;鐜?#28729;朵俊?#20229;锛屼?#23678;槸瀵?#28766;?#20426;?#20229;銆?br />Director 鍚戝悗绔?#26440;?#37711;?#28725;?#28766;?#20426;?#20229;锛屽?#21464;細鏀?#37714;?#28051;涓?#37818;?#28051;涓?#37928;勫灞浜哄憳鍒楄〃.
Director 闇瑕?#28051;?#23011;?#28051;?#28725;?#28766;寮鎴块棿锛岀劧鍚?#38315;氱煡鍚庣鎴块棿鍦板潃銆?br />鍚庣灏嗘?#22359;棿鍦板潃?#21843;鍏?redis, ?#21159;鍚?#37715;嶇璇?#37721;?#37714;版?#22359;棿鍦板潃锛屽氨閫氱煡 frontendclient锛?#29825;?#37916;?#28729;?#26473;?#37711;?#37812;块棿銆?br />

## test/cmd/frontendclient


妯℃嫙澶у巺鏈?#37812;?#32513;勯槦鏈?#38171;?#26473;?#37818;?#37715;嶇API, 璇锋眰鍖归?#23943;帺瀹??#27110;浼?#37510;?#37812;?#37716;?#37722;?#28751;?#37824;?#37714;版?#22359;棿鏈?DGS)鐨?#37734;板潃(Assignment)銆?br />
Player 瀹為檯涓婃槸涓涓槦浼?#38171;屽叾涓璉D瀛楁?#27128;?#25956;绌?#37837;?#37714;嗛殧鐨?#28598;?#28051;狪D.
铏界劧鍙傛暟?#34987;鍨嬮兘?#27128; Player, CreatePlayer() 鍙傛暟涓烘暣涓槦浼?#38171;?#38000;?GetUpdates() 鍙傛?#29256;槸鍗?#28051;?#37916;?#28729;?#37510;?br />
main() 涓?#37714;涘缓澶?#28051;?#37916;?#28729;?#38171;屾瘡涓?#37916;?#28729;?#29835;冪敤 GetUpdates() 浠?#38014;?#37721;栫粨鏋?#38171;実o waitForResults() 涓?#28598;?#37918;嗙粨鏋?#37510;?br />waitForResult() 璇?#37721;?#23092;?#28051;?#37928;?#37718;归?#23943;粨鏋?#38171;屽?#23338;叆 resultsChan锛?#28003;嗗?#34249;儚 resultsChan 浠呯敤浜?#37813;?#37719;?#38171;?#37510;?br />鎵鏈?#37916;?#28729;?#37722;堝苟鍒?g 瀹?#28186;?#28051;?#38171;岀劧鍚?#29835;冪敤 CreatePlayer() 璇锋眰鍖归厤銆?br />
cleanup() 璋冪敤 DeletePlayer() 鏉?#37714;?#38340;?#37718;归厤璇锋眰锛屼笉浠?#38343;鍒?#38340;ゆ暣涓槦浼?#38171;?#28052;?#38343;瑕?#37714;?#38340;?#37719;?#28051;?#37916;?#28729;?#37510;?br />
濂藉儚鏈鍚?#37721;栫粨鏋滄病鍙?#28725;?#37734;版柟锛屽簲璇?#28000;?resultChan 涓?#38014;?#37721;?Assignment, ?#33503;?#25956;璇?#37734;板潃 udpClient().

鐪嬩簡璇?#32448;?#28186;嬪氨?#24434;浠?#37918;?#29785;?frontend.proto

## examples/backendclient


MatchObject.Properties ?#27128;浠?testprofile.json 璇?#37721;?#37928;?#38171;屽簲璇?#37824;?#37722;?#28051;?Profile ?#27128;鍚?#37831;村?#30028;偣锛?br />pbProfile ?#27128; MatchObject锛孭rofile 绛?#37722;屼簬 MatchObject?
Profile 鐨勫畾涔夋槸 MMF 鎵闇鐨?#37813;鏈?#37721;傛暟銆?br />`pbProfile.Properties = jsonProfile` 閲嶅?#23940;簡2閬?#37510;?br />
ListMatches()鍒?#37713;?#26473;?#28051;狿rofile鐨?#37813;鏈?#37718;归厤銆?br />鏀?#37714;?#28051;涓?#37718;归?#23941;悗锛岄?#33636;敤CreateAssignments()灏嗘?#22359;棿鏈嶅?#26495;潃, 绉?#28051;?Assignment, 鍙?#38315;?#37714;版墍鏈夋父鎴?#28729;?#37812;?#32468;?#37510;?br />

## cmd/frontendapi


CreatePlayer() 灏?Player 瀵硅薄?#21843;鍏?redis, 閿?#37706;?#28051;?Player.Id, ?#34987;鍨?#28051;?HSET銆?br />瀵?Player 鐨勬瘡涓?attribute锛屾坊鍔?#37714;?ZSET 涓?#37720;?#37510;?br />姝?#28598;?Player ?#27128;涓缁?#37916;?#28729;?#37510;?br />
GetUpdates() 姣忛殧2s璇?#37721;杛edis, Player鏁版嵁鏈?#37721;?#37718;栨椂?#27688;鍙?#38315;?#37510;傛澶?Player ?#27128;鍗?#28051;?#37916;?#28729;?#37510;?br />
濡傛灉CreatePlayer()涓槦浼嶅彧鏈?#28051;涓?#37916;?#28729;?#38171;?br />鍒欏啓鍏?#37928;凱layer涓嶨etUpdates()涓?#29831;?#37721;?#37928;?#37916;?#28729;舵槸鍚?#28051;涓猺edis閿?#37510;?br />

## cmd/backendapi


CreateMatch() 涓?profile ?#34987;鍨?#28051;?MatchObject, ?#27128;涓涓?#23011;旇禌鐨勯檺鍒?#37833;?#28000;?#37510;?br />profile 鍏堝啓鍏?redis, 閿?#28051;?profile.Id.
`requestKey := xid() + "." + profile.Id`,
?#33503;灏?requestKey 鍔?#37711;?redis 闆?#37722;?"profileq"銆?br />?#21159;鍚?#23011;?s?#29025;璇?redis, 鐪嬫槸鍚?#37832;?requestKey 閿?#37713;虹幇锛屽苟杩?#37733;?#29831;?#37706;?#37510;?br />
ListMatch() 姣?s璋冪敤涓娆?CreateMatch().

DeleteMatch() 浠?#28000;?#37714;?#38340;?Id 杩?#28051;?#38335;?#37510;?br />
CreateAssignments() 涓?#28598;?#28051;槦浼?#29825;?#32515;瓵ssignment, 鍗?#37812;块棿鍦板潃銆?br />閬嶅?#21976;墍鏈塕oster涓?#37928;凱layer瀵硅薄锛屽湪redis涓?#29825;?#32515;瓵ssignment.
(Assignment 鏇?#37824;?#37722;?#38171;屼細瑙?#37721;戝?#23943;鏇存柊銆?
灏嗘墍鏈?Player.Id 浠?"proposed" 绉?#37714;?"deindexed"锛?#26473;?#28051;?#28051;槸 ZSET, 鍒?#37706;?#28051;?#37716;?#37711;ユ椂?#26879;銆?br />Roster 搴?#29831;ユ槸姣旇禌涓?#37928;勯樀钀?#38171;屽?#20636;孩?#26591;锛岃?#28615;柟锛屾瘡涓?#38339;?#38016;?#28051;彲鏈?#28598;?#28051;槦浼?#37510;?br />
DeleteAssignments() 浠?#28000;?#38316;嶅?#21976;墍鏈?Player 瀵硅薄鏉?#37714;?#38340;?Assignment 瀛楁銆?br />

## cmd/mmforc


鍖归厤娴佺?#23339;槸鐢?mmforc (matchmaking function orchestrator) 鎺?#37714;?#37928;?#37510;?br />
mmforc 姣?#32457;?#28000;?redis 鐨?profileq 涓?#37721;?#37713;?100 涓?#37812;愬憳, 鍏?#28051;?profileq ?#27128;涓猻et?#34987;鍨?#38171;?br />浣跨敤鍛?#28000;?#28051;篳SPOP profileq 100`.

瀵?#23011;?#28051;?profile, 鍒涘缓涓涓?k8s 浠诲姟锛?br />
```
    // Kick off the job asynchrnously
    go mmfunc(ctx, profile, cfg, defaultMmfImages, clientset, &pool)
```

姣忛殧10s, 杩?#37832;?#37813;鏈?#37718;归厤浠诲姟?#20824;瀹?#37812;愬悗锛?#38343;瑕?`checkProposals`, 鍗?#37714;涘缓 evaluator 浠诲姟銆?br />
profileq 涓?#37928;?#37711;冪礌 profile 涓哄瓧绗?#28051;?#38171;宮atchObjectID.profileID銆?br />浠?profileID 涓?#38335;?#38171;屽彲浠?#28000;?redis 璇?#37721;?profile 鐨勫唴瀹? profile ?#27128;涓?MatchObject 瀵硅薄銆?br />
profile 鐨勫唴瀹?#28051;?json 涓?#38171;屽叾涓?"jsonkeys.mmfImages" 涓?mmf (matchmaking function) 闀滃儚銆?br />
濡傛灉profile璇?#37721;?#28598;?#29840;?#38171;?#37812;?#38000;?mmfImages 涓?#32460;?#38171;屽垯浣跨敤?#31919;璁?#37928;勯?#28355;儚銆俶mfImages 鏈?#37833;ヤ細鏀寔澶?#28051;?#38336;滃儚銆?br />
閫?#26473;?MMF_* 鐜?#28583;?#37721;?#38322;?#28028;?#37711;?#37722;?#32457;嶅?#20635;暟.

## mmf


绀?#28186;?#38171;歟xamples\functions\golang\manual-simple

浠?#37916;?#28583;?#37721;?#38322;?"MMF_PROFILE_ID" 瑙f瀽鍑?profileID, ?#33503;鍚?redis ?#29025;璇?HGETALL) profile锛孒SET ?#34987;鍨?#37510;?br />
浠?profile 涓?#37721;?pools 瀛楁锛?#37719;?#37718;归厤鏉?#28000;?#37510;?br />pools 鍒?#28051;?#28598;?#28051;?pool, 姣?#28051;?pool 涓?#37832;?#28598;?#28051;?filter, 姣?#28051;?filter 鍚?redis 鍙栫鍚?#37928;?Player.

profile ?#25956;鍒?#28000;?#28051;嬪?#26945;锛?br />
* "properties.playerPool"
  json涓?#38171;屾槸涓浜?#26473;囨护鏉?#28000;?#38171;屽“mmr: 100-999”
* "properties.roster"
  json涓? ?#27128;澶?#28051;槦浼嶅ぇ灏?#38171;屽 “red: 4”

绀?#28186;?#29785;?#38171;歚examples\backendclient\profiles\testprofile.json`

### 绠鍗?#37718;归厤杩?#32459;?/h3>
simple mmf 鐨?#37718;归厤杩?#32459;嬪涓?#38171;?br />
1. 浠?redis ?#29025;璇?profile锛岃幏鍙?#26473;囨护鏉?#28000;?#37724;屽?#21231;槦浼嶅ぇ灏?br />1. 姣?#28051;?#26473;囨护鏉?#28000;?#37722;?redis ?#29025;璇?#38171;?#37813;鏈夌粨鏋?#37928;勪氦闆?#28051;哄彲閫?#37812;愬憳
1. 鍘?#38340;?ignoreList, 鍗?#37832;杩?800s 鍐呭凡鍖归厤鎴?#37716;?#37928;?#37812;愬憳锛?#37719;?proposal 鍜?deindexed ZSET 鍒楄〃銆?br />1. 濡傛?#28355;彲閫?#37812;愬?#27193;釜鏁板お灏?#38171;屽垯 insufficient_players ?#33503;閫鍑?br />1. 鍒?#38320;嶅?#21226;釜?#27110;浼?#37812;愬憳
1. 鍚?redis 璁板綍?#31912;鏋?br />

### ?#31912;鏋?/h3>
profile 涓坊鍔?roster锛?#37719;?#37722;勯樀钀?#37812;愬憳鍚?#37719;?#38171;屽瓨鍏?prososalKey.
?#32346;瀛樹笉鍒嗛槦浼?#37928;?#37812;愬憳鍚?#37719;?#37510;?br />?#21159;鍚?#37722;?"proposalq" ?#22346;鍔?prososalKey

### 缁嗚妭


poolRosters 浠?(pool鍚? filter attribute) 涓?#38335;?#38171;屽?#28051;?Player ID 鍒楄〃.
?#32346;瀛樹粠 redis ?#29025;璇?#37928;勭鍚堟潯浠?#37928;?Player ID.

overlaps 浠?pool 鍚?#28051;?#38335;?#38171;屼繚瀛?#32471;?#37722;?#29831;ool涓?#37813;鏈塮ilter鐨?Player ID 鍒楄〃锛屽幓闄?ignore list.

rosters ?#27128; profile 涓?#37928;?"properties.rosters" 瀛楁銆備笉?#29025;浣曠敤锛?br />閬嶅巻 rosters, 涓?#23011;?#28051;?#38339;?#38016;?#37928;勬瘡涓猵layer鎵?#37714;板?#29808;簲pool鐨凱layerID, ?#32346;瀛?#37714;?mo.Rosters.
鍏?#28051;?profileRosters 濂藉?#24532;病?#25956;銆?br />


閲戝簡 2019-01-31 10:21 鍙戣〃璇?#29825;?/a>
]]>璇曠敤 go modhttp://www.2676208.com/jinq0123/archive/2018/12/26/216141.html閲戝簡閲戝簡Wed, 26 Dec 2018 02:07:00 GMThttp://www.2676208.com/jinq0123/archive/2018/12/26/216141.htmlhttp://www.2676208.com/jinq0123/comments/216141.htmlhttp://www.2676208.com/jinq0123/archive/2018/12/26/216141.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/216141.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/216141.html璇曠敤 go mod
(閲戝簡鐨勪笓鏍?2018.12)

Go 1.11 鏀寔 module.

浠g爜?#31497;闇瑕?#37734;?GOPATH/src 鐩綍涓?#37510;?br />
鍏?#37714;濆?#23338;寲妯?#37735;?#38171;?#37922;?#37812;?`go.mod`

E:\temp
λ mkdir -p testmod\hello

E:\temp
λ cd testmod\hello\

E:\temp\testmod\hello
λ go mod init github.com/jinq0123/hello
go: creating new go.mod: module github.com/jinq0123/hello


鍒涘缓 `hello.go`

package main

import (
    "fmt"
    "rsc.io/quote"
)

func main() {
    fmt.Println(quote.Hello())
}


鏋勫?#28888;椂?#23012; `golang.org/x/text` 杩炰笉涓?#38171;?br />
E:\temp\testmod\hello
λ go build
go: golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c: unrecog
nized import path "golang.org/x/text" (https fetch: Get https://g
olang.org/x/text?go-get=1: dial tcp 216.239.37.1:443: connectex:
A socket operation was attempted to an unreachable network.)
go: error loading module requirements


`go.mod` ?#22346;鍔?br />
replace golang.org/x/text => github.com/golang/text v0.3.0


?#21159;鍚?#37835;勫?#21700;氨鎴?#37716;熶簡锛?br />
E:\temp\testmod\hello
λ go build
go: finding github.com/golang/text v0.3.0
go: downloading rsc.io/sampler v1.3.0
go: downloading github.com/golang/text v0.3.0

E:\temp\testmod\hello
λ hello.exe
Hello, world.


濡傛?#28352;笉鍔?#37911;?#37832;?#37721;?#38171;屽?#27406;細?#23012;閿?#38171;?br />
go.mod:9: replacement module without version must be directory path (rooted or starting with ./ or ../)


Go 1.11.1 replace 杩?#37832;?#38338;锛?#28000;嶄細璇?#37733;?#26473;?#37818;?#37720;?#37734;板潃銆?#37929;?#37715;嶇増鏈?1.11.4 ?#24434;浠ョ敤銆?br />
鍙?#38000;?#38171;?br />https://github.com/golang/go/wiki/Modules


閲戝簡 2018-12-26 10:07 鍙戣〃璇?#29825;?/a>
]]>grpc鍔燭LS鍔犲?#21975;拰浠?#37911;?#29825;?#29831;?/title><link>http://www.2676208.com/jinq0123/archive/2018/11/26/216081.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Mon, 26 Nov 2018 02:39:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/11/26/216081.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/216081.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/11/26/216081.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/216081.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/216081.html</trackback:ping><description><![CDATA[<div><h1>grpc鍔燭LS鍔犲?#21975;拰浠?#37911;?#29825;?#29831;?/h1><br />(閲戝簡鐨勪笓鏍?2018.11)<br /><br />?#25956; golang 鍒涘缓 grpc 鏈嶅姟锛屽紑鍚?TLS 鍔犲瘑锛屽苟閲囩敤浠?#37911;?#29825;?#29831;?#37510;?br />?#21159;鍚庣敤 C++ 鍜?golang 鍒?#37714;?#37714;涘缓瀹?#37812;?#32468;?#26473;?#37818;?#37832;嶅姟?#27346;銆?br /><br />鍙?#38000;?#38171;?br />https://segmentfault.com/a/1190000007933303<br /><br /><h2>鏈嶅姟?#27346;</h2><br /><span style="color: #800000; font-family: Courier;">import (</span><br /><span style="color: #800000; font-family: Courier;">    ...</span><br /><span style="color: #800000; font-family: Courier;">    grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/auth"</span><br /><span style="color: #800000; font-family: Courier;">    "google.golang.org/grpc"</span><br /><span style="color: #800000; font-family: Courier;">    "google.golang.org/grpc/credentials"</span><br /><span style="color: #800000; font-family: Courier;">)</span><br /><br /><span style="color: #800000; font-family: Courier;">func main() {</span><br /><span style="color: #800000; font-family: Courier;">    listen, err := net.Listen("tcp", ":12345")</span><br /><span style="color: #800000; font-family: Courier;">    if err != nil {</span><br /><span style="color: #800000; font-family: Courier;">        grpclog.Fatalf("failed to listen: %v", err)</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br />    <br /><span style="color: #800000; font-family: Courier;">    // TLS璁?#29831;?/span><br /><span style="color: #800000; font-family: Courier;">    creds, err := credentials.NewServerTLSFromFile("keys/server.crt", "keys/server.key")</span><br /><span style="color: #800000; font-family: Courier;">    if err != nil {</span><br /><span style="color: #800000; font-family: Courier;">        grpclog.Fatalf("Failed to generate credentials %v", err)</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br />    <br /><span style="color: #800000; font-family: Courier;">    // 瀹?#28186;嬪寲grpc Server, ?#33503;寮鍚疶LS璁?#29831;?/span><br /><span style="color: #800000; font-family: Courier;">    s := grpc.NewServer(grpc.Creds(creds),</span><br /><span style="color: #800000; font-family: Courier;">        grpc_auth.UnaryServerInterceptor(auth.Authenticate),</span><br /><span style="color: #800000; font-family: Courier;">        grpc_auth.StreamServerInterceptor(auth.Authenticate))</span><br />    <br /><span style="color: #800000; font-family: Courier;">    // 娉ㄥ唽HelloService</span><br /><span style="color: #800000; font-family: Courier;">    pb.RegisterHelloServer(s, HelloService)</span><br /><span style="color: #800000; font-family: Courier;">    grpclog.Println("Listen on " + Address + " with TLS")</span><br /><span style="color: #800000; font-family: Courier;">    s.Serve(listen)</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br />鍏?#28051;?server.key ?#27128;绉?#38333;?#38171;宻erver.crt ?#27128;鑷?#32475;?#37722;?#29831;?#28052;?#38171;屽涓?#37922;?#37812;?#38171;?br /><br /><span style="color: #0000ff;">$ openssl genrsa -out server.key 2048</span><br /><span style="color: #0000ff;">$ openssl req -new -x509 -sha256 -key server.key \</span><br /><span style="color: #0000ff;"> -out server.crt -days 36500 \</span><br /><span style="color: #0000ff;"> -subj /C=CN/ST=Shanghai/L=Songjiang/O=ztgame/OU=tech/CN=mydomain.ztgame.com/emailAddress=myname@ztgame.com</span><br /><br />?#29025;鐪?#29831;?#28052;?#37826;?#28000;?br /><span style="color: #0000ff;">$ openssl x509 -in server.crt -noout -text</span><br /><br /><br />`auth.Authenticate` 濡?#28051;?#38171;?#28003;?#28051;?interceptor, 瀵?#23011;?#28051;?#29831;锋眰杩涜浠?#37911;岄獙璇?#37510;?br /><br /><span style="color: #800000; font-family: Courier;">package auth</span><br /><br /><span style="color: #800000; font-family: Courier;">import (</span><br /><span style="color: #800000; font-family: Courier;">    "context"</span><br /><span style="color: #800000; font-family: Courier;">    "sync"</span><br /><br /><span style="color: #800000; font-family: Courier;">    "google.golang.org/grpc/codes"</span><br /><span style="color: #800000; font-family: Courier;">    "google.golang.org/grpc/metadata"</span><br /><span style="color: #800000; font-family: Courier;">    "google.golang.org/grpc/status"</span><br /><span style="color: #800000; font-family: Courier;">)</span><br /><br /><span style="color: #800000; font-family: Courier;">// from token.yaml file</span><br /><span style="color: #800000; font-family: Courier;">var tokenToAppName = &sync.Map{}</span><br /><br /><span style="color: #800000; font-family: Courier;">func init() {</span><br /><span style="color: #800000; font-family: Courier;">    tokenToAppName.Store("test", "test")</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">// XXX load tokenToAppName from file</span><br /><br /><span style="color: #800000; font-family: Courier;">// Authenticate checks that a token exists and is valid.</span><br /><span style="color: #800000; font-family: Courier;">// It removes the token from the context and</span><br /><span style="color: #800000; font-family: Courier;">//  stores the app name of the token in the returned context</span><br /><span style="color: #800000; font-family: Courier;">func Authenticate(ctx context.Context) (context.Context, error) {</span><br /><span style="color: #800000; font-family: Courier;">    token, err := extractHeader(ctx, "authorization-token")</span><br /><span style="color: #800000; font-family: Courier;">    if err != nil {</span><br /><span style="color: #800000; font-family: Courier;">        return ctx, err</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><span style="color: #800000; font-family: Courier;">    // Remove token from headers from here on</span><br /><span style="color: #800000; font-family: Courier;">    ctx = purgeHeader(ctx, "authorization-token")</span><br /><br /><span style="color: #800000; font-family: Courier;">    valAppName, ok := tokenToAppName.Load(token)</span><br /><span style="color: #800000; font-family: Courier;">    if !ok {</span><br /><span style="color: #800000; font-family: Courier;">        return ctx, status.Errorf(codes.Unauthenticated, "no app for token '%s'", token)</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><span style="color: #800000; font-family: Courier;">    appName := valAppName.(string)</span><br /><span style="color: #800000; font-family: Courier;">    return context.WithValue(ctx, keyAppName{}, appName), nil</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">func extractHeader(ctx context.Context, header string) (string, error) {</span><br /><span style="color: #800000; font-family: Courier;">    md, ok := metadata.FromIncomingContext(ctx)</span><br /><span style="color: #800000; font-family: Courier;">    if !ok {</span><br /><span style="color: #800000; font-family: Courier;">        return "", status.Error(codes.Unauthenticated, "no headers in request")</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><br /><span style="color: #800000; font-family: Courier;">    authHeaders, ok := md[header]</span><br /><span style="color: #800000; font-family: Courier;">    if !ok {</span><br /><span style="color: #800000; font-family: Courier;">        return "", status.Error(codes.Unauthenticated, "no header in request")</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><br /><span style="color: #800000; font-family: Courier;">    if len(authHeaders) != 1 {</span><br /><span style="color: #800000; font-family: Courier;">        return "", status.Error(codes.Unauthenticated, "more than 1 header in request")</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><br /><span style="color: #800000; font-family: Courier;">    return authHeaders[0], nil</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">func purgeHeader(ctx context.Context, header string) context.Context {</span><br /><span style="color: #800000; font-family: Courier;">    md, _ := metadata.FromIncomingContext(ctx)</span><br /><span style="color: #800000; font-family: Courier;">    mdCopy := md.Copy()</span><br /><span style="color: #800000; font-family: Courier;">    mdCopy[header] = nil</span><br /><span style="color: #800000; font-family: Courier;">    return metadata.NewIncomingContext(ctx, mdCopy)</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">type keyAppName struct{}</span><br /><br /><span style="color: #800000; font-family: Courier;">// GetAppName can be used to extract app name stored in a context.</span><br /><span style="color: #800000; font-family: Courier;">func GetAppName(ctx context.Context) string {</span><br /><span style="color: #800000; font-family: Courier;">    // Authenticate()涔嬪悗蹇呯劧瀛?#37734;╝pp name</span><br /><span style="color: #800000; font-family: Courier;">    return ctx.Value(keyAppName{}).(string)</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br />`tokenToAppName` ?#27128;涓涓猰ap, 灏?#37722;?#23049;?#37928;勪护鐗?#37828;犲?#21226;负搴旂敤鍚?#37510;?br />姣?#28051;?#25652;旂敤锛?#37719;崇敤鎴?#38171;?#37714;嗛厤涓涓?#28000;?#37911;?#38171;?#37837;规嵁浠?#37911;屽彲?#29025;鍒?#29831;ョ敤鎴锋槸鍚?#37722;?#23049;?#38171;?#28000;?#37721;婄敤鎴?#37928;?#37711;?#28000;栦俊?#20229;銆?br />杩?#38322;屽彧闇瑕佸簲?#25956;鍚?#37510;?br /><br />姣?#28051;?#29831;锋眰灏?#29835;冪敤 `Authenticate()`, 璇ユ柟娉?#28751;?#28000;?http 澶?#38014;?#37721;?#29831;锋眰鐨勪护鐗?#38171;屾煡鎵?#28725;瑰簲鐨勫簲?#25956;鍚?#38171;?br />ctx 涓?#28751;?#37714;?#38340;?#28000;?#37911;?#38171;?#37831;?#37817;?#37812;愬簲?#25956;鍚?#37510;?br /><br />`GetAppName()`灏?#28000;?ctx 涓?#38014;?#37721;?#25652;旂敤鍚?#37510;?br /><br />鏈嶅姟?#26591;娉?#28729;?#37916;板涓?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">func (s MailServer) Get(ctx context.Context, r *pb.GetRequest) (*pb.GetResponse, error) {</span><br /><span style="color: #800000; font-family: Courier;">    app := auth.GetAppName(ctx)</span><br /><span style="color: #800000; font-family: Courier;">    body, err := db.NewGetter(app).GetMailBody(r.MailIndex)</span><br /><span style="color: #800000; font-family: Courier;">    return &pb.GetResponse{</span><br /><span style="color: #800000; font-family: Courier;">        Result: getResult(err),</span><br /><span style="color: #800000; font-family: Courier;">        Body:   body,</span><br /><span style="color: #800000; font-family: Courier;">    }, nil</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br />鍏?#38014;?#37721;?#25652;旂敤鍚?#38171;岀劧鍚?#37837;规嵁搴旂敤鍚嶈幏鍙?#37929;?#25652;?#37928;勬?#29256;嵁杩?#37733;?#37510;?br /><br /><h2>瀹?#37812;?#32468;?/h2><br /><h3>golang</h3><br /><span style="color: #800000; font-family: Courier;">    // Create the client TLS credentials</span><br /><span style="color: #800000; font-family: Courier;">    creds, err := credentials.NewClientTLSFromFile("key/server.crt", "mydomain.ztgame.com")</span><br /><span style="color: #800000; font-family: Courier;">    if err != nil {</span><br /><span style="color: #800000; font-family: Courier;">        panic(fmt.Errorf("could not load tls cert: %s", err))</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><br /><span style="color: #800000; font-family: Courier;">    // We don't need to error here, as this creates a pool and connections</span><br /><span style="color: #800000; font-family: Courier;">    // will happen later</span><br /><span style="color: #800000; font-family: Courier;">    conn, _ := grpc.Dial(</span><br /><span style="color: #800000; font-family: Courier;">        serviceURL,</span><br /><span style="color: #800000; font-family: Courier;">        grpc.WithTransportCredentials(creds),</span><br /><span style="color: #800000; font-family: Courier;">        grpc.WithPerRPCCredentials(auth.TokenAuth{</span><br /><span style="color: #800000; font-family: Courier;">            Token: "test",</span><br /><span style="color: #800000; font-family: Courier;">        }))</span><br /><br /><span style="color: #800000; font-family: Courier;">    cli := pb.NewMailClient(conn)</span><br /><br />瀹?#37812;?#32468;?#37721;?#38343;瑕?server.crt, 鍏?#28051;?#37718;?#37722;?#37832;嶅姟?#27346;鐨?#37711;?#38333;?#37510;?br />NewClientTLSFromFile() 鐨勭2涓?#37721;傛?#29256;槸涓煙鍚?#38171;屾槸 server.crt 涓?#37928;勫煙鍚?#37510;?br />鐩?#37715;嶆祴璇?#38339;舵杩樻病鏈夋寮忓煙鍚?#29825;?#32515;?#38171;?#37813;浠?#26440;?#37711;?#28051;涓?#37816;?#28729;氬煙鍚嶇敤浜庨獙璇?server.crt 涓?#37928;勫煙鍚?#37510;?br />鐢?#27996;?#37916;?#28583;?#26473;?#29723;屾椂锛屽簲璇ヤ笉闇瑕?#26473;?#28051;煙鍚?#38171;屽彲浠?#37929;?#37818;ユ煡璇?DNS 杩涜?#23684;獙璇?#37510;?br /><br />Dial() 杈?#37711;?#28051;涓?WithPerRPCCredentials ?#25956;浜?#28000;?#37911;岄獙璇?#37510;?br /><br />auth.TokenAuth 闇瑕?#28729;炵幇 PerRPCCredentials 鎺?#37721;?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">package auth</span><br /><br /><span style="color: #800000; font-family: Courier;">import (</span><br /><span style="color: #800000; font-family: Courier;">    "context"</span><br /><span style="color: #800000; font-family: Courier;">)</span><br /><br /><span style="color: #800000; font-family: Courier;">type TokenAuth struct {</span><br /><span style="color: #800000; font-family: Courier;">    Token string</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">func (t TokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {</span><br /><span style="color: #800000; font-family: Courier;">    return map[string]string{</span><br /><span style="color: #800000; font-family: Courier;">        "authorization-token": t.Token,</span><br /><span style="color: #800000; font-family: Courier;">    }, nil</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">func (TokenAuth) RequireTransportSecurity() bool {</span><br /><span style="color: #800000; font-family: Courier;">    return true</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br />"authorization-token" ?#27128;瀹?#37812;?#32468;?#37724;?#37832;嶅姟?#27346;绾?#28729;氬ソ鐨刪ttp璁?#29831;?#28598;村瓧绗?#28051;?#37510;?br /><br /><h3>C++</h3><br />C++ 绔?#37928;?#28729;?#37812;?#32468;?#28000;g爜姣攇olang鐨?#32459;嶅?#23942;潅锛屽洜涓?grpc C++ 搴撴病鏈?grpc-go 鎴愮啛銆?br /><br />浠g爜鍙傜収 grpc 绀?#28186;?greeter_async_client2.cc:<br /><br /><span style="color: #800000; font-family: Courier;">int main(int argc, char** argv) {</span><br /><span style="color: #800000; font-family: Courier;">    grpc::SslCredentialsOptions ssl_options;</span><br /><span style="color: #800000; font-family: Courier;">    ssl_options.pem_root_certs = SERVER_CRT;</span><br /><span style="color: #800000; font-family: Courier;">    // Create a default SSL ChannelCredentials object.</span><br /><span style="color: #800000; font-family: Courier;">    auto channel_creds = grpc::SslCredentials(ssl_options);</span><br /><span style="color: #800000; font-family: Courier;">    grpc::ChannelArguments cargs;</span><br /><span style="color: #800000; font-family: Courier;">    cargs.SetSslTargetNameOverride("gamemail.ztgame.com");  // 濡傛灉鍔犱簡 DNS 灏变笉?#25956;杩?#28051;簡</span><br /><br /><span style="color: #800000; font-family: Courier;">    auto call_creds = grpc::MetadataCredentialsFromPlugin(</span><br /><span style="color: #800000; font-family: Courier;">        std::unique_ptr<grpc::MetadataCredentialsPlugin>(new TokenAuthenticator(TOKEN)));</span><br /><br /><span style="color: #800000; font-family: Courier;">    auto compsited_creds = grpc::CompositeChannelCredentials(channel_creds, call_creds);</span><br /><br /><span style="color: #800000; font-family: Courier;">    // Create a channel using the credentials created in the previous step.</span><br /><span style="color: #800000; font-family: Courier;">    auto channel = grpc::CreateCustomChannel("1.2.3.4:8000", compsited_creds, cargs);</span><br /><br /><span style="color: #800000; font-family: Courier;">    // Instantiate the client.</span><br /><span style="color: #800000; font-family: Courier;">    MailClient tester(channel);</span><br /><span style="color: #800000; font-family: Courier;">    ...</span><br /><br /><span style="color: #800000; font-family: Courier;">    return 0;</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br />鍥?#28051;?C++ ?#30149;鏈夋彁渚?#28000;庢枃浠?#29831;?#37721;?server.crt 鐨?#37818;?#37721;?#38171;?#37813;浠?#37734;?#23005;?#37929;?#37818;ョ敤?#31777;涓涓父閲忓瓧绗?#28051;?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">    ssl_options.pem_root_certs = SERVER_CRT;</span><br /><br />SERVER_CRT ?#30078;涔夊涓?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">// server.crt 鐨勫唴瀹?/span><br /><span style="color: #800000; font-family: Courier;">const char SERVER_CRT[] = R"(</span><br /><span style="color: #800000; font-family: Courier;">-----BEGIN CERTIFICATE-----</span><br /><span style="color: #800000; font-family: Courier;">TjERMA8GA1UECAwIU2hhbmdoYWkxEjAQBgNVBAcMCVNvbmdqaWFuZzEPMA0GA1UE</span><br /><span style="color: #800000; font-family: Courier;">...</span><br /><span style="color: #800000; font-family: Courier;">E6v50RCQgtWGmna+oy1I2UTVABdjBFnyKPEuz106mBfOhT6cg80hBHVgrV7sLHq8</span><br /><span style="color: #800000; font-family: Courier;">76QolJm8yzZPL1qpiO4dKHHsCP6R</span><br /><span style="color: #800000; font-family: Courier;">-----END CERTIFICATE-----</span><br /><span style="color: #800000; font-family: Courier;">)";</span><br /><br />TokenAuthenticator ?#30078;涔夊涓?#38171;屾槸涓?#38007;畾涔夎璇佹彃浠?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">// TokenAuthenticator ?#25956;鏉?#37824;寔浠?#37911;?#29825;?#29831;?/span><br /><span style="color: #800000; font-family: Courier;">// https://grpc.io/docs/guides/auth.html</span><br /><span style="color: #800000; font-family: Courier;">class TokenAuthenticator : public grpc::MetadataCredentialsPlugin {</span><br /><span style="color: #800000; font-family: Courier;">public:</span><br /><span style="color: #800000; font-family: Courier;">  TokenAuthenticator(const std::string& token) : token_(token) {}</span><br /><br /><span style="color: #800000; font-family: Courier;">  grpc::Status GetMetadata(</span><br /><span style="color: #800000; font-family: Courier;">      grpc::string_ref service_url, grpc::string_ref method_name,</span><br /><span style="color: #800000; font-family: Courier;">      const grpc::AuthContext& channel_auth_context,</span><br /><span style="color: #800000; font-family: Courier;">      std::multimap<grpc::string, grpc::string>* metadata) override {</span><br /><span style="color: #800000; font-family: Courier;">    metadata->insert(std::make_pair("authorization-token", token_));</span><br /><span style="color: #800000; font-family: Courier;">    return grpc::Status::OK;</span><br /><span style="color: #800000; font-family: Courier;">  }</span><br /><br /><span style="color: #800000; font-family: Courier;">private:</span><br /><span style="color: #800000; font-family: Courier;">  std::string token_;</span><br /><span style="color: #800000; font-family: Courier;">};</span><br /> </div><img src ="http://www.2676208.com/jinq0123/aggbug/216081.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-11-26 10:39 <a href="http://www.2676208.com/jinq0123/archive/2018/11/26/216081.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>vs2017 linux 缂?#29831;?#26440;撳嚭鏀?#37812;?vs 鏍?#23534;?/title><link>http://www.2676208.com/jinq0123/archive/2018/11/21/216073.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Wed, 21 Nov 2018 02:57:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/11/21/216073.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/216073.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/11/21/216073.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/216073.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/216073.html</trackback:ping><description><![CDATA[<div>vs2017 linux 缂?#29831;?#26440;撳嚭鏀?#37812;?vs 鏍?#23534;?/div><div></div><div><div>(閲戝簡鐨勪笓鏍?2018.11)</div></div><div></div><div><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; "> 1</span> <span style="color: #008000; ">#</span><span style="color: #008000; ">!/usr/bin/python </span><span style="color: #008000; "><br /></span><span style="color: #008080; "> 2</span> <span style="color: #008000; ">#</span><span style="color: #008000; "> -*- coding: utf-8 -*-  </span><span style="color: #008000; "><br /></span><span style="color: #008080; "> 3</span> <span style="color: #008000; "></span><span style="color: #000000; "><br /></span><span style="color: #008080; "> 4</span> <span style="color: #000000; "></span><span style="color: #800000; ">'''</span><span style="color: #800000; "><br /></span><span style="color: #008080; "> 5</span> <span style="color: #800000; ">gcc2vs.py<br /></span><span style="color: #008080; "> 6</span> <span style="color: #800000; "><br /></span><span style="color: #008080; "> 7</span> <span style="color: #800000; ">鍔熻兘锛?br /></span><span style="color: #008080; "> 8</span> <span style="color: #800000; ">灏?#37715;?#37714;?#37833;?#28051;璯cc鐨?#32514;?#29831;?#26440;撳嚭鏍?#23534;忚浆鎴恦s鏍?#23534;?#38171;岀敤浜巚s璺宠浆鍒?#38335;?#29831;?#29723;?#37510;?br /></span><span style="color: #008080; "> 9</span> <span style="color: #800000; ">vs2017 linux 缂?#29831;?#26440;撳嚭涓?nbsp;gcc 鏍?#23534;?#38171;屾棤娉?#37904;?#37713;?#29882;宠浆锛屽锛?br /></span><span style="color: #008080; ">10</span> <span style="color: #800000; ">/var/tmp/src/db<img src="http://www.2676208.com/Images/dot.gif" alt="" />e/Linux-Debug/Src/Team.cpp:16:1: 閿?#29831;?#38171;?#8216;x’?#31497;?#27128;涓涓被鍨嬪悕<br /></span><span style="color: #008080; ">11</span> <span style="color: #800000; ">椤昏浆涓簐s鏍?#23534;? 濡?br /></span><span style="color: #008080; ">12</span> <span style="color: #800000; ">/var/tmp/src/db<img src="http://www.2676208.com/Images/dot.gif" alt="" />e/Linux-Debug/Src/Team.cpp(16):1: 閿?#29831;?#38171;?#8216;x’?#31497;?#27128;涓涓被鍨嬪悕<br /></span><span style="color: #008080; ">13</span> <span style="color: #800000; "><br /></span><span style="color: #008080; ">14</span> <span style="color: #800000; ">濡?#28003;?#28003;跨敤锛?br /></span><span style="color: #008080; ">15</span> <span style="color: #800000; "><br /></span><span style="color: #008080; ">16</span> <span style="color: #800000; ">棣?#37711;?#26916;?#28729;夎 python, ?#33503;瀹夎 pyperclip<br /></span><span style="color: #008080; ">17</span> <span style="color: #800000; ">pip install pyperclip<br /></span><span style="color: #008080; ">18</span> <span style="color: #800000; "><br /></span><span style="color: #008080; ">19</span> <span style="color: #800000; ">鍋?#29825;?#37832;?#37826;?#28000;?#28051;?nbsp;d:/tools/gcc2vs.py,<br /></span><span style="color: #008080; ">20</span> <span style="color: #800000; ">vs璁?#32515;?#28598;?#38318;?#23480;?#37711;?#38171;氬伐鍏?>澶?#38318;?#23480;?#37711;?>?#22346;鍔?br /></span><span style="color: #008080; ">21</span> <span style="color: #800000; ">  鏍囬锛歡cc2vs(&V)<br /></span><span style="color: #008080; ">22</span> <span style="color: #800000; ">  鍛?#28000;?#38171;歱ython.exe<br /></span><span style="color: #008080; ">23</span> <span style="color: #800000; ">  鍙傛暟锛歞:/tools/gcc2vs.py<br /></span><span style="color: #008080; ">24</span> <span style="color: #800000; ">  閫?#28051;?浣跨敤杈撳嚭绐?#37721;?<br /></span><span style="color: #008080; ">25</span> <span style="color: #800000; "><br /></span><span style="color: #008080; ">26</span> <span style="color: #800000; ">鍙?#38000;?#38171;歏S2010鎵?#37716;ㄦ坊鍔?#28598;?#38318;?#23480;?#37711;峰?#23677;揩鎹?#38335;?nbsp; <br /></span><span style="color: #008080; ">27</span> <span style="color: #800000; ">https://www.cnblogs.com/ChinaHook/p/4698733.html<br /></span><span style="color: #008080; ">28</span> <span style="color: #800000; "><br /></span><span style="color: #008080; ">29</span> <span style="color: #800000; ">褰揕inux鏋勫缓杈撳嚭鍚?#38171;岀偣鍑?#26440;撳嚭绐?#37721;?#38171;宑trl-A 閫夋嫨鍏?#38318;?#38171;宑trl-C 澶嶅埗杈撳嚭鍒板壀鍒?#37833;?#38171;?br /></span><span style="color: #008080; ">30</span> <span style="color: #800000; ">?#21159;鍚?nbsp;alt-T,V 杩?#29723;屾坊鍔?#37928;?#28598;?#38318;?#23480;?#37711;?nbsp;gcc2vs(&V), 鏇?#37824;?#26440;撳嚭鏍?#23534;?#38171;岀劧鍚庡氨?#24434;浠?#37904;?#37713;?#38335;?#29831;?#29882;宠浆?#31777;銆?br /></span><span style="color: #008080; ">31</span> <span style="color: #800000; "></span><span style="color: #800000; ">'''</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">32</span> <span style="color: #000000; "><br /></span><span style="color: #008080; ">33</span> <span style="color: #000000; "></span><span style="color: #0000FF; ">import</span><span style="color: #000000; "> re<br /></span><span style="color: #008080; ">34</span> <span style="color: #000000; "></span><span style="color: #0000FF; ">import</span><span style="color: #000000; "> pyperclip<br /></span><span style="color: #008080; ">35</span> <span style="color: #000000; "><br /></span><span style="color: #008080; ">36</span> <span style="color: #000000; "></span><span style="color: #008000; ">#</span><span style="color: #008000; "> 寰?#37831;?#37817;?#37928;?#37837;?#23534;?/span><span style="color: #008000; "><br /></span><span style="color: #008080; ">37</span> <span style="color: #008000; "></span><span style="color: #000000; ">pattern </span><span style="color: #000000; ">=</span><span style="color: #000000; "> re.compile(r</span><span style="color: #800000; ">'</span><span style="color: #800000; ">/var/tmp/src/<img src="http://www.2676208.com/Images/dot.gif" alt="" /><img src="http://www.2676208.com/Images/dot.gif" alt="" />..-<img src="http://www.2676208.com/Images/dot.gif" alt="" />.-<img src="http://www.2676208.com/Images/dot.gif" alt="" />.-<img src="http://www.2676208.com/Images/dot.gif" alt="" />.-<img src="http://www.2676208.com/Images/dot.gif" alt="" /><img src="http://www.2676208.com/Images/dot.gif" alt="" /><img src="http://www.2676208.com/Images/dot.gif" alt="" /><img src="http://www.2676208.com/Images/dot.gif" alt="" />/Linux-Debug/(.*):([0-9]*):([0-9]*): </span><span style="color: #800000; ">'</span><span style="color: #000000; ">)<br /></span><span style="color: #008080; ">38</span> <span style="color: #000000; "><br /></span><span style="color: #008080; ">39</span> <span style="color: #000000; ">test_lines_src </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #800000; ">'''</span><span style="color: #800000; "><br /></span><span style="color: #008080; ">40</span> <span style="color: #800000; ">/var/tmp/src/db71a8ec-90bb-2838-98df-2dd35e71166e/Linux-Debug/003_servers/103_LobbyServer/Src/Team.cpp:16:1: 閿?#29831;?#38171;?#8216;x’?#31497;?#27128;涓涓被鍨嬪悕<br /></span><span style="color: #008080; ">41</span> <span style="color: #800000; ">鐢?#37812;愬け璐?#37510;?br /></span><span style="color: #008080; ">42</span> <span style="color: #800000; "></span><span style="color: #800000; ">'''</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">43</span> <span style="color: #000000; ">test_lines_dst </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #800000; ">'''</span><span style="color: #800000; "><br /></span><span style="color: #008080; ">44</span> <span style="color: #800000; ">003_servers/103_LobbyServer/Src/Team.cpp(16):1: 閿?#29831;?#38171;?#8216;x’?#31497;?#27128;涓涓被鍨嬪悕<br /></span><span style="color: #008080; ">45</span> <span style="color: #800000; ">鐢?#37812;愬け璐?#37510;?br /></span><span style="color: #008080; ">46</span> <span style="color: #800000; "></span><span style="color: #800000; ">'''</span><span style="color: #000000; "><br /></span><span style="color: #008080; ">47</span> <span style="color: #000000; "></span><span style="color: #0000FF; ">assert</span><span style="color: #000000; "> test_lines_dst </span><span style="color: #000000; ">==</span><span style="color: #000000; "> re.sub(pattern, r</span><span style="color: #800000; ">'</span><span style="color: #800000; ">\1(\2):\3: </span><span style="color: #800000; ">'</span><span style="color: #000000; ">, test_lines_src)<br /></span><span style="color: #008080; ">48</span> <span style="color: #000000; "><br /></span><span style="color: #008080; ">49</span> <span style="color: #000000; "></span><span style="color: #008000; ">#</span><span style="color: #008000; "> 鍓?#37714;?#37833;?#28051;?#37928;刧cc鏍?#23534;?#26440;撳嚭</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">50</span> <span style="color: #008000; "></span><span style="color: #000000; ">src </span><span style="color: #000000; ">=</span><span style="color: #000000; "> pyperclip.paste()<br /></span><span style="color: #008080; ">51</span> <span style="color: #000000; "></span><span style="color: #008000; ">#</span><span style="color: #008000; "> ?#27974;鎴恦s鏍?#23534;?/span><span style="color: #008000; "><br /></span><span style="color: #008080; ">52</span> <span style="color: #008000; "></span><span style="color: #000000; ">dst </span><span style="color: #000000; ">=</span><span style="color: #000000; "> re.sub(pattern, r</span><span style="color: #800000; ">'</span><span style="color: #800000; ">\1(\2):\3: </span><span style="color: #800000; ">'</span><span style="color: #000000; ">, src)<br /></span><span style="color: #008080; ">53</span> <span style="color: #000000; "></span><span style="color: #0000FF; ">print</span><span style="color: #000000; ">(dst)<br /></span><span style="color: #008080; ">54</span> <span style="color: #000000; "></span></div></div><img src ="http://www.2676208.com/jinq0123/aggbug/216073.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-11-21 10:57 <a href="http://www.2676208.com/jinq0123/archive/2018/11/21/216073.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>瑙?#37712;硋s2017?#26852;娉?#28729;夎闂http://www.2676208.com/jinq0123/archive/2018/11/12/216052.html閲戝簡閲戝簡Mon, 12 Nov 2018 02:19:00 GMThttp://www.2676208.com/jinq0123/archive/2018/11/12/216052.htmlhttp://www.2676208.com/jinq0123/comments/216052.htmlhttp://www.2676208.com/jinq0123/archive/2018/11/12/216052.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/216052.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/216052.html瑙?#37712;硋s2017?#26852;娉?#28729;夎闂

(閲戝簡鐨勪笓鏍?2018.11)

浠?#28729;?#32515;?#28051;嬭?#25106;簡 vs_community__1600125377.1541561546.exe锛?#28003;嗘槸杩?#29723;屽?#22798;?#21614;椂?#26852;娉?#37713;虹幇浜у搧閫夋嫨鐣岄潰銆?br />
?#29025;鐪?Temp 鐩綍涓?#37928;勬棩蹇?#38171;屾病鏈?#37721;戠幇閿?#29831;?#37510;?br />
鎼滅储涓涓?#38171;屽?#25120;幇鏈?#28598;?#38322;?#37928;?#37722;岀被閿?#29831;?#38171;?br />
* VS : How to fix stuck Visual Studio Community installation problem
    https://www.howtosolutions.net/2015/08/solving-installation-is-stuck-problem-in-visual-studio-community-edition/
* Resolving Installation Issues with Visual Studio 2017
    http://rion.io/2017/02/17/resolving-installation-issues-with-visual-studio-2017/
* Unable to start vs_installer.exe to install VS2017 Community
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/fc8f5a04-8687-48dd-987e-1cfac67566a1/unable-to-start-vsinstallerexe-to-install-vs2017-community?forum=vssetup
* VS 2017 Installer quits before starting
    https://developercommunity.visualstudio.com/content/problem/8993/vs-2017-installer-quits-before-starting.html
* VS2017?#26852;娉?#26473;?#37711;?#28729;夎?#21615;?#23684;潰闂鐨?#29785;?#37712;虫柟娉?- 鍘氱Н钖?#37721;?#38171;屾寔涔?#28000;?#37805;?- CSDN鍗氬
    https://blog.csdn.net/qq951127336/article/details/71036868
* VS2017瀹夎?#21614;椂鑷?#37716;?#38315;鍑篲yanggy_鏂版氮鍗氬
    http://blog.sina.com.cn/s/blog_702b606a0102y6n3.html

浣嗘槸?#20824;?#30149;鏈夌敤銆?br />
浠?#28000;?#28051;婃柟妗?#28051;簡瑙?#37714;?#38171;宍C:\Program Files (x86)\Microsoft Visual Studio\Installer`?#24434;?#20824;瀛?#37734;?#37735;忔枃浠?#38171;?#37813;浠ユ棤娉?#28729;夎銆?br />浣嗘槸娓?#37918;?#28052;嬪悗閲嶆柊涓嬭浇锛?#28000;嶇劧?#27128;鍚?#37837;锋?#21613;喌銆?br />
璇曠潃杩?#29723;屼簡鍏?#28051;?#37928;?vs_installer.exe锛屽脊鍑虹?#23684;潰璇?#37832;?#37711;?#28729;规?#38335;?#29831;?#38171;屽彲浠?#38315;夋嫨淇?#28598;?#37510;?br />淇?#28598;?#28052;嬪悗锛寁s_installer.exe ?#27688;鍑虹幇浜у搧閫夋嫨鐣岄潰?#31777;銆?br />
?#21159;鍚?#37712;?#26473;?#29723;?vs_community__1600125377.1541561546.exe锛屽氨?#24434;浠?#37713;虹幇浜у搧閫夋嫨鐣岄潰?#31777;銆?br />
闂?#27194;彲?#20824;?#27128;杩?#28051;?Installer 瀹夎?#21612;笉瀵?#38171;屽彲?#20824;?#27128;閫夋嫨?#31777;閿?#29831;?#37928;勭増鏈?#38171;屽垹闄?#37722;?#38322;嶆柊涓嬭浇杩樻槸涓鏍?#38171;?#26473;?#28610;藉彲浠?#37813;?#37716;?#28103;?#28598;?#28051;涓?#37510;?br />
?#24135;鍦?#23005;?#37734;?#28729;夎 vs2017.


閲戝簡 2018-11-12 10:19 鍙戣〃璇?#29825;?/a>
]]>gotest ?#27128;鏈?#32514;撳瓨鐨?/title><link>http://www.2676208.com/jinq0123/archive/2018/10/29/216026.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Mon, 29 Oct 2018 10:47:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/10/29/216026.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/216026.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/10/29/216026.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/216026.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/216026.html</trackback:ping><description><![CDATA[<div>gotest ?#27128;鏈?#32514;撳瓨鐨?br /><br />(閲戝簡鐨勪笓鏍?2018.10)<br /><br />?#25956; gotest 杩?#29723;?#28051;涓祴璇?#38171;屽線 mongodb 涓?#37819;?#37711;?#28051;鏉?#38171;屽?#25120;幇鏈夋椂鐏?#38171;?#37832;夋椂?#31497;鐏?#37510;?br /><br />鍥?#28051;?#38335;?#29831;?#37734;版鐤?mgo ?#25956;閿欎簡锛?#38000;?#29840;逛簡?#31497;灏戞椂?#26879;銆?br />鏈缁?#37721;戠?#29256;槸鍥?#28051;?gotest ?#27128;鏈?#32514;撳瓨鐨?#38171;?#26440;撳嚭鐨勬槸涓婃杩?#29723;?#37928;勭粨鏋?#38171;?#28003;嗘槸?#33503;?#30149;鏈?#28729;為檯杩?#29723;?#28000;g爜銆?br /><br />杩?#29723;?#37832;?#37825;堟槸鍥?#28051;?#28000;g爜鍒?#37824;?#26473;?#38171;屾祴璇曟椂浼氬?#28858;檯杩?#29723;?#37510;?br /><br />鏈缁?#28052;熸槸?#26852;鎰?#38338;村?#25120;幇鐨?#37510;?#32513;?mgo 寮鍚簡璋?#29831;?#37827;?#36423;?#38171;岀劧鍚?#23011;?#26440;?娆?#26473;?#29723;?#38171;屽?#25120;幇杈撳?#28888;槸涓鏍?#37928;?#38171;?br />鍙?#37832;?#28051;琛屼笉鍚?#38171;?br /><br /><span style="color: #0000ff;">ok      mail-server/server      0.519s</span><br /><span style="color: #0000ff;">ok      mail-server/server      (cached)</span><br /><br />鏄?#32429;?#37828;?#32448;轰簡绗?娆℃槸缂撳瓨銆?#37715;嶉潰杩?#29723;屼簡鍑?#37719;?#23046;¢兘蹇界暐?#31777; cached 杩?#28051;?#26440;撳嚭銆?br /><br />涓轰簡绂?#23005;?#32514;撳瓨锛屽彲鍔?#28051;?-count=1 鍙傛暟锛?br /><span style="color: #800000;">go test -count=1</span><br /><br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/216026.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-10-29 18:47 <a href="http://www.2676208.com/jinq0123/archive/2018/10/29/216026.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>open-match鐨剅edis鏁版嵁http://www.2676208.com/jinq0123/archive/2018/09/28/215964.html閲戝簡閲戝簡Fri, 28 Sep 2018 06:01:00 GMThttp://www.2676208.com/jinq0123/archive/2018/09/28/215964.htmlhttp://www.2676208.com/jinq0123/comments/215964.htmlhttp://www.2676208.com/jinq0123/archive/2018/09/28/215964.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215964.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215964.html

open-match鐨剅edis鏁版嵁


(閲戝簡鐨勪笓鏍?2018.9)

open-match ?#27128;Google鐨?#23534;婧愭父鎴?#37718;归厤鏈嶆?#21976;灦銆?br />
https://github.com/GoogleCloudPlatform/open-match

鍖归厤涓?#37813;?#25956;鍒?#37928;?#37916;?#28729;?#37825;版嵁浼氫繚瀛?#37734;?redis 涓?#37510;傛煡鐪?br />`open-match\internal\statestorage\redis\playerq\playerq.go`
?#24434;浠ヤ簡瑙edis?#32346;瀛?#37928;勬?#29256;嵁銆?br />
redis涓?#37832;?#28000;?#28051;嬮敭鍊?#37510;?br />

playerID


鐜?#28729;禝D褰?#28641;?#38171;歚bfd09c94d646493f834a4abe83a5a68c`, ?#34987;鍨?#28051;?hash. 鏈?#28000;?#28051;嬪?#26945;锛?br />

playerID.properties


?#32346;瀛?#37916;?#28729;?#37825;版嵁鐨刯son涓?#37510;?#28641;?#38171;?br />
{
    "char.paladin": 1538102377,
    "map.eastworld": 1538102377,
    "mmr.rating": 1740,
    "mode.ctf": 1538102377,
    "timestamp.enter": 1538102377
}


鐜?#28729;?#37825;版嵁鐨勬瘡椤?#37706;奸兘瑕佹眰涓烘?#23384;暟.

indices


set ?#34987;鍨?#38171;屼繚瀛?#37813;鏈?#37916;?#28729;?#37825;版嵁閿?#37510;?#28641;?#38171;?br />
127.0.0.1:6379> smembers indices
1) "timestamp.enter"
2) "map.eastworld"
3) "mmr.rating"
4) "mode.ctf"
5) "char.paladin"

濂藉?#24532;病?#25956;鍒?#37510;?br />

鐜?#28729;?#37825;版嵁閿?/h2>
濡?`timestamp.enter`, ?#34987;鍨?#28051;?zset.
姣?#28051;?#37916;?#28729;?#37825;版嵁閿兘寤?#32468;嬩簡涓涓?#37818;?#25652;忛泦锛?#37816;夎鐜?#28729;?#37825;版嵁鍊?#37818;?#25652;?#38171;?#37812;愬?#27193;负 playerID銆?br />
渚嬪锛?br />
127.0.0.1:6379> zrange mmr.rating 1 3 WITHSCORES
1) "ef3736ef2f7941f1a159f279703d5f58"
2) "746"
3) "17ca3bf3a2134c2c90cbe48ebc29f9cb"
4) "891"
5) "b6450b311f3f413595e824897015c462"
6) "891"


閲戝簡 2018-09-28 14:01 鍙戣〃璇?#29825;?/a>
]]>docker build 璁?#32515;?#28000;?#37918;?/title><link>http://www.2676208.com/jinq0123/archive/2018/09/26/215949.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Wed, 26 Sep 2018 09:37:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/09/26/215949.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215949.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/09/26/215949.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215949.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215949.html</trackback:ping><description><![CDATA[<div>docker build 璁?#32515;?#28000;?#37918;?br /><br />(閲戝簡鐨勪笓鏍?2018.9)<br /><br />Dockerfile.frontendapi 涓?#37832;?`RUN go get`, 闇瑕?#29825;?#32515;?#28000;?#37918;?#37510;?br /><br /><span style="color: #0000ff;">docker build . -f Dockerfile.frontendapi \</span><br /><span style="color: #0000ff;">    -t registry.cn-shanghai.aliyuncs.com/jinq0123/openmatch-frontendapi:dev \</span><br /><span style="color: #0000ff;">    --network host \</span><br /><span style="color: #0000ff;">    --build-arg HTTP_PROXY=http://127.0.0.1:1080 \</span><br /><span style="color: #0000ff;">    --build-arg HTTPS_PROXY=http://127.0.0.1:1080</span><br /><br />鍥?#28051;?docker build 浼氬湪涓涓?#28729;瑰櫒鍐?#37813;?#29723;?#38171;?#37813;浠?#26916;?#37816;囧畾 network 涓?host, 浣?#28052;嬪彲浠?#26473;?#37818;?#37832;?#37832;?#37928;勪唬鐞?#37510;?br /><br />鍙?#38000;?#38171;?br />https://stackoverflow.com/questions/22179301/how-do-you-run-apt-get-in-a-dockerfile-behind-a-proxy<br /><br /><span style="color: #0000ff;">[root@pppdc9prda2y java]# docker build </span><br /><span style="color: #0000ff;">  --build-arg https_proxy=$HTTP_PROXY --build-arg http_proxy=$HTTP_PROXY </span><br /><span style="color: #0000ff;">  --build-arg HTTP_PROXY=$HTTP_PROXY --build-arg HTTPS_PROXY=$HTTP_PROXY </span><br /><span style="color: #0000ff;">  --build-arg NO_PROXY=$NO_PROXY  --build-arg no_proxy=$NO_PROXY -t java .</span><br /> </div><img src ="http://www.2676208.com/jinq0123/aggbug/215949.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-09-26 17:37 <a href="http://www.2676208.com/jinq0123/archive/2018/09/26/215949.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>K8s鑾?#37721;朜odePorthttp://www.2676208.com/jinq0123/archive/2018/09/04/215903.html閲戝簡閲戝簡Tue, 04 Sep 2018 07:17:00 GMThttp://www.2676208.com/jinq0123/archive/2018/09/04/215903.htmlhttp://www.2676208.com/jinq0123/comments/215903.htmlhttp://www.2676208.com/jinq0123/archive/2018/09/04/215903.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215903.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215903.htmlK8s鑾?#37721;朜odePort

(閲戝簡鐨勪笓鏍?2018.9)

灏?#37832;嶅姟?#25956;NodePort鏆?#38343;?#37714;板缃?#38171;?#28051;?#38316;?#37711;嶇鍙?#37712;?#32464;?#38171;屼笉鎸囧畾NodePort,
 鑰屾槸璁﹌8s鑷?#37716;?#38315;夋嫨涓涓?#32468;?#37721;?#37510;?br /> 
$ cat get_node_port.yaml
kind: Service
apiVersion: v1
metadata:
  name: jq-service
spec:
  type: NodePort
  selector:
    app: MyApp
  ports:
  - protocol: TCP
    port: 80

$ kubectl apply -f get_node_port.yaml
service "jq-service" configured
$ kubectl describe svc/jq-service
Name:                     jq-service
Namespace:                default
Labels:                   <none>
Annotations:              kubectl...
Selector:                 app=MyApp
Type:                     NodePort
IP:                       10.104.228.187
Port:                     <unset>  80/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  32115/TCP
Endpoints:                <none>
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>


?#24434;浠?#37930;?#37714;発8s鍒?#38320;嶄簡NodePort 32115銆?br />
?#21159;鍚?#38343;瑕佽幏鍙?#26473;?#28051;?#37716;?#37804;?#37928;凬odePort锛?#28000;?#38315;氱煡瀹?#37812;?#32468;?#26473;?#37818;?#29831;?#32468;?#37721;?#37510;?br />
package main

import (
    "context"
    "fmt"
    "log"
    "io/ioutil"

    "github.com/ghodss/yaml"
    "github.com/ericchiang/k8s"
    corev1 "github.com/ericchiang/k8s/apis/core/v1"
)

func main() {
    data, err := ioutil.ReadFile("config")
    if err != nil {
        panic(err)
    }

    // Unmarshal YAML into a Kubernetes config object.
    var config k8s.Config
    if err := yaml.Unmarshal(data, &config); err != nil {
        panic(err)
    }

    client, err := k8s.NewClient(&config)
    // client, err := k8s.NewInClusterClient()
    if err != nil {
        log.Fatal(err)
    }

    var svc corev1.Service
    if err := client.Get(context.Background(), "default", "jq-service", &svc); err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%d\n", *svc.Spec.Ports[0].NodePort)
}

杩?#29723;屾椂闇瑕?#28598;嶅埗config: `cp ~/.kube/config .`


閲戝簡 2018-09-04 15:17 鍙戣〃璇?#29825;?/a>
]]>鍒?#38340;?#38341;愭?#37928;刧it submodulehttp://www.2676208.com/jinq0123/archive/2018/08/30/215889.html閲戝簡閲戝簡Thu, 30 Aug 2018 02:58:00 GMThttp://www.2676208.com/jinq0123/archive/2018/08/30/215889.htmlhttp://www.2676208.com/jinq0123/comments/215889.htmlhttp://www.2676208.com/jinq0123/archive/2018/08/30/215889.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215889.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215889.html鍒?#38340;?#38341;愭?#37928;刧it submodule

(閲戝簡鐨勪笓鏍?2018.8)

姝e父鐨剆ubmodule浼氬湪 .gitmodule 鏂?#28000;?#28051;?#38171;孴ortoiseGit ?#32048;鏈?Submodule Update 鑿?#37719;?#37510;?br />杩?#37832;?#28051;绉嶉?#24877;?#37928;?submodule, .gitmodule 鏂?#28000;?#28051;?#37930;嬩笉鍒板畠锛屾棤娉?update.
golang寮鍙?#28051;?#37928;剉endor鐩綍涓嬬?#24531;父浼氫笉灏忓?#20905;坊鍔?#28051;涓?#29999;?.git 鐨?#37929;綍锛屽氨鍙?#37812;愪簡涓涓?#37707;?#37928;剆ubmodule.
?#25956; Repo-browser 鐪?#26473;?#28051;?#37929;綍?#27128;涓猻ubmodule閾?#37818;? clone 鍑烘潵?#27688;鍙?#37832;?#28051;涓?#32460;?#37929;綍銆?br />
鍒?#38340;?#26473;?#28051;猻ubmodule?#31497;?#20824;?#25956; git delete, ?#24385;浜ゆ椂?#32048;?#23012;閿?#38171;?br />
git.exe add -f [...]

fatal: pathspec 'src/vendor/github.com/grpc-ecosystem/grpc-opentracing' did not match any files

git did not exit cleanly (exit code 128)

git delete ?#22487;鐩綍涔熸棤娉曟彁浜?#37510;?br />
浣嗘槸?#24434;浠?#37929;?#37818;?#37714;?#38340;?#38171;堜笉?#25956;git delete锛? ?#21159;鍚庢彁浜ゅ苟Push. 濂藉儚鍙?#37832;?#26473;?#28051;?#37716;?#23049;?#37510;?br />




閲戝簡 2018-08-30 10:58 鍙戣〃璇?#29825;?/a>
]]>grpc涓?#37928;刣ns璐熻浇鍧?#29723;?/title><link>http://www.2676208.com/jinq0123/archive/2018/08/29/215886.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Wed, 29 Aug 2018 02:59:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/08/29/215886.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215886.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/08/29/215886.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215886.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215886.html</trackback:ping><description><![CDATA[<div>grpc涓?#37928;刣ns璐熻浇鍧?#29723;?br /><br />(閲戝簡鐨勪笓鏍?2018.8)<br /><br />grpc-go 涓?#28641;?#28051;?#26473;?#37818;?#37832;嶅姟?#27346;锛?#29831;锋眰灏?#37734;?#28598;?#28051;狪P涔嬮棿?#30086;?#27974;銆?br /><br /><span style="color: #993300; font-family: Courier;">    conn, err := grpc.Dial(</span><br /><span style="color: #993300; font-family: Courier;">        "dns:///rng-headless:8081",</span><br /><span style="color: #993300; font-family: Courier;">        grpc.WithBalancerName(roundrobin.Name),</span><br /><span style="color: #993300; font-family: Courier;">        grpc.WithInsecure())</span><br /><br />鏍?#37713;?#37928;?#37929;?#37837;?#37722;嶅簲璇ユ槸杩?#37837;?#37928;?#38171;歚"dns://authority/endpoint_name"`,<br />姝?#28598;?authority 涓?#32460;?#38171;?#29831;?#29785;?#38171;歨ttps://github.com/grpc/grpc/blob/master/doc/naming.md<br /><br />鏈嶅姟?#27346;寮3涓?#28729;?#28186;?#38171;?#37813;鏈夎?#38155;眰鍦?涓?#28729;?#28186;?#28051;婅疆?#27974;锛?br /><br /><span style="color: #0000ff;">[jinqing@host-10-2-3-4 RoundRobin]$ kubectl run -it --rm jinqing-roundrobin --image=jinq0123/roundrobin:4</span><br /><span style="color: #0000ff;">If you don't see a command prompt, try pressing enter.</span><br /><span style="color: #0000ff;">2018/08/28 10:18:01 request 7754383576636566559</span><br /><span style="color: #0000ff;">2018/08/28 10:18:02 request 2543876599219675746</span><br /><span style="color: #0000ff;">2018/08/28 10:18:03 request 927204261937181213</span><br /><span style="color: #0000ff;">2018/08/28 10:18:04 request 7754383576636566559</span><br /><span style="color: #0000ff;">2018/08/28 10:18:05 request 2543876599219675746</span><br /><span style="color: #0000ff;">2018/08/28 10:18:06 request 927204261937181213</span><br /><span style="color: #0000ff;">...</span><br /><br />鏈嶅姟?#27346;杩?#37733;?#28051;涓?#38341;?#37832;烘暟锛屼笉鍚屽疄渚?#37928;勯殢鏈烘暟?#31497;鍚?#37510;?#28000;g爜?#27128;浠?br />https://github.com/kcollasarundell/balancing-on-k8s 淇?#37824;?#37928;?#37510;?br /><br /><span style="color: #993300; font-family: Courier;">...</span><br /><span style="color: #993300; font-family: Courier;">const (</span><br /><span style="color: #993300; font-family: Courier;">        port = ":8081"</span><br /><span style="color: #993300; font-family: Courier;">)</span><br /><br /><span style="color: #993300; font-family: Courier;">type server struct{}</span><br /><br /><span style="color: #993300; font-family: Courier;">var r int64</span><br /><br /><span style="color: #993300; font-family: Courier;">func init(){</span><br /><span style="color: #993300; font-family: Courier;">    rand.Seed(time.Now().UnixNano())</span><br /><span style="color: #993300; font-family: Courier;">    r = rand.Int63()</span><br /><span style="color: #993300; font-family: Courier;">}</span><br /><br /><span style="color: #993300; font-family: Courier;">func (s *server) Rng(context.Context, *rng.Source) (*rng.RN, error) {</span><br /><span style="color: #993300; font-family: Courier;">        return &rng.RN{RN: r}, nil</span><br /><span style="color: #993300; font-family: Courier;">}</span><br /><br /><span style="color: #993300; font-family: Courier;">func main() {</span><br /><span style="color: #993300; font-family: Courier;">        lis, err := net.Listen("tcp", port)</span><br /><span style="color: #993300; font-family: Courier;">        if err != nil {</span><br /><span style="color: #993300; font-family: Courier;">                log.Fatalf("failed to listen: %v", err)</span><br /><span style="color: #993300; font-family: Courier;">        }</span><br /><span style="color: #993300; font-family: Courier;">        s := grpc.NewServer()</span><br /><span style="color: #993300; font-family: Courier;">        rng.RegisterRngServer(s, &server{})</span><br /><span style="color: #993300; font-family: Courier;">        // Register reflection service on gRPC server.</span><br /><span style="color: #993300; font-family: Courier;">        reflection.Register(s)</span><br /><br /><span style="color: #993300; font-family: Courier;">        if err := s.Serve(lis); err != nil {</span><br /><span style="color: #993300; font-family: Courier;">                log.Fatalf("failed to serve: %v", err)</span><br /><span style="color: #993300; font-family: Courier;">        }</span><br /><span style="color: #993300; font-family: Courier;">}</span><br /><br />鍏?#32514;?#29831;?#38171;?#37813;撳寘鎴?#38336;滃儚锛岀劧鍚庣敤 `balancing-on-k8s\backend\kube.yaml` 杩?#29723;?#38171;?br /><span style="color: #0000ff;">kubectl apply -f kube.yaml</span><br /><br />`backend\kube.yaml` 鍒涘?#36720;簡涓涓?ClusterIP 鏈嶅姟鍜?#28051;涓?Headless 鏈嶅姟锛?#38318;?#32515;蹭簡 3 涓?#37832;嶅姟?#27346;瀹?#28186;?#37510;?br /><span style="color: #0000ff;">[jinqing@host-10-2-3-4 RoundRobin]$ kubectl get svc</span><br /><span style="color: #0000ff;">NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)             AGE</span><br /><span style="color: #0000ff;">kubernetes     ClusterIP   10.96.0.1       <none>        443/TCP             93d</span><br /><span style="color: #0000ff;">rng-cluster    ClusterIP   10.111.30.205   <none>        8081/TCP            4h</span><br /><span style="color: #0000ff;">rng-headless   ClusterIP   None            <none>        8081/TCP,8080/TCP   4h</span><br /><br />瀹?#37812;?#32468;槸涓涓?#32480;鍗?#37928;刧rpc, ?#30078;?#26882;鍙?#38315;佽?#38155;眰锛?#37813;?#37719;?#26473;?#37733;?#37928;勯殢鏈烘暟銆?br />`balancing-on-k8s\clientSideBalancer\RoundRobin\main.go`涓?#37928;?#37734;板潃闇瑕佹坊鍔?#32468;?#37721;?#38171;?br />?#31497;?#21159;grpc浼氬幓杩?#37818;?443 绔?#37721;?#38000;屽け璐?#37510;?br /><br />鎵?#28729;?#37722;?#38171;屾祴鍒板ぇ姒?鍒嗛挓鍚?#37813;嶇湅鍒?#29840;熻浇?#27974;绉?#37510;?#32514;?#28729;?#37722;庝細绔?#37719;?#37922;熸晥銆?br /><span style="color: #0000ff;">kubectl scale --replicas=5 deployment/rng</span><br /><br />濡傛灉?#27128; ClusterIP 鏈嶅姟, 鍒?#37832;嶅姟鍚嶅?#29808;簲涓涓狢lusterIP;<br />濡傛灉?#27128; Headless 鏈嶅姟锛屽垯鏈嶅姟鍚嶅?#29808;簲鍚勪釜Pod鐨処P:<br /><br /><span style="color: #0000ff;">/ # nslookup rng-headless</span><br /><span style="color: #0000ff;">Server:         10.96.0.10</span><br /><span style="color: #0000ff;">Address:        10.96.0.10#53</span><br /><br /><span style="color: #0000ff;">Name:   rng-headless.default.svc.cluster.local</span><br /><span style="color: #0000ff;">Address: 10.244.3.27</span><br /><span style="color: #0000ff;">Name:   rng-headless.default.svc.cluster.local</span><br /><span style="color: #0000ff;">Address: 10.244.0.108</span><br /><span style="color: #0000ff;">Name:   rng-headless.default.svc.cluster.local</span><br /><span style="color: #0000ff;">Address: 10.244.2.66</span><br /><br /><span style="color: #0000ff;">/ # nslookup rng-cluster</span><br /><span style="color: #0000ff;">Server:         10.96.0.10</span><br /><span style="color: #0000ff;">Address:        10.96.0.10#53</span><br /><br /><span style="color: #0000ff;">Name:   rng-cluster.default.svc.cluster.local</span><br /><span style="color: #0000ff;">Address: 10.111.30.205</span><br /><br /><span style="color: #0000ff;">/ #</span><br /><br />濡傛?#28355;幓闄?"dns:///", 浠?#28000;呮槸?#29017;鍚嶅姞绔?#37721;?#38171;?br /><br /><span style="color: #993300; font-family: Courier;">conn, err := grpc.Dial(</span><br /><span style="color: #993300; font-family: Courier;">        "rng-headless:8081",</span><br /><span style="color: #993300; font-family: Courier;">        grpc.WithBalancerName(roundrobin.Name),</span><br /><span style="color: #993300; font-family: Courier;">        ...</span><br /><br />鍒?#37721;細璇锋眰鍚?#28051;涓?#28729;?#28186;?#37510;?#37721;?#37832;夊綋璇?#28729;?#28186;媝od琚?#37714;?#38340;?#37722;?#37813;嶄?#27692;?#22248;崲鍒板彟涓涓?#28729;?#28186;?#37510;?br />浣跨敤缂?#28729;规椂鍙戠幇浼氫紭鍏?#37714;?#38340;ゆ病鏈?#28729;?#37812;?#32468;?#26473;?#37818;?#37928;?#28729;?#28186;?#37510;?br />?#25956;2涓?#28729;?#37812;?#32468;?#26473;?#37818;?#37714;颁笉鍚?#37832;嶅姟?#27346;瀹?#28186;?#38171;岀劧鍚?#32514;?#28729;?#28051;?瀹?#28186;?#38171;屽氨?#24434;浠?#37930;?#37714;?#29831;锋眰鍒囨崲銆?br /><br />濡傛灉瀹?#37812;?#32468;?#37724;?#37832;嶅姟?#27346;?#26271;閲忓緢澶?#38171;?#26473;?#28051;猟ns璐熻浇鍧?#29723;?#28751;变笉鍚?#38315;備簡锛屽洜涓?#28729;?#37812;?#32468;細杩?#37818;?#23011;?#28051;?#37832;嶅姟?#27346;瀹?#28186;?#37510;?br /><br />鍙?#38000;?#38171;?br />Exploring Kubernetes Service Discovery and loadbalancing ( https://kca.id.au/post/k8s_service/ )<br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/215886.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-08-29 10:59 <a href="http://www.2676208.com/jinq0123/archive/2018/08/29/215886.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>鎵?#37832;?#26473;?#29723;?Unity Grpchttp://www.2676208.com/jinq0123/archive/2018/08/12/215842.html閲戝簡閲戝簡Sun, 12 Aug 2018 04:24:00 GMThttp://www.2676208.com/jinq0123/archive/2018/08/12/215842.htmlhttp://www.2676208.com/jinq0123/comments/215842.htmlhttp://www.2676208.com/jinq0123/archive/2018/08/12/215842.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215842.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215842.html鎵?#37832;?#26473;?#29723;?Unity Grpc

(閲戝簡鐨勪笓鏍?2018.8)

* 瀹夎 Unit2018, 鏀寔 .NET 4.x
* 鍒涘缓涓涓?#26916;?#37929;?#38171;屽紑鍚?.NET 4.x
    Edit->Project Settings->Player->Other Settings
      ->Configuration->Script Runtime Version->.Net 4.x Equivalent
* 浠?https://packages.grpc.io/ 鐨?Daily Builds 涓嬭浇鏈鏂?#37928;?br />    grpc-protoc_windows_x86-VERSION.zip
    grpc_unity_package.VERSION.zip
* grpc_unity_package.VERSION.zip
    瑙?#37720;?#37714;?Assets 鐩綍涓?br />* 浠?github grpc 澶嶅埗 examples/protos/helloworld.proto 涓?Assets/protos/helloworld.proto
* 鍒涘缓 Assets/Scripts/Greeter/, ?#33503;鍦?#29831;?#37929;綍涓?#26473;?#29723;?br />    protoc.exe -I../../../protos --csharp_out=. ../../../protos/helloworld.proto --grpc_out=. --plugin=protoc-gen-grpc=grpc_csharp_plugin.exe
    + 闇瑕?#37711;?#28000;?grpc-protoc_windows_x86-VERSION.zip 瑙?#37720;?protoc.exe锛実rpc_csharp_plugin.exe
    + 鐢?#37812;?Helloworld.cs HelloworldGrpc.cs
* 瀹?#37812;?#32468;?#28000;g爜
    + 鍒涘缓Channel杩?#37818;?#37832;嶅姟?#27346;
    channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
    + 鍒涘缓瀹?#37812;?#32468;苟鍙戝嚭璇锋眰
    var client = new Greeter.GreeterClient(channel);
    HelloReply reply = client.SayHello(new HelloRequest { Name = "Jin Qing" });
* 瀹屾暣浠g爜瑙?#38171;歨ttps://gitee.com/jinq0123/unity-grpc-sample
* 鏈鍚?#37813;撳寘瀹夎鍒版墜鏈烘祴璇?#38315;?#26473;?br />


閲戝簡 2018-08-12 12:24 鍙戣〃璇?#29825;?/a>
]]>k8s闆嗙兢澶杇o瀹?#37812;?#32468;?#32448;?#28186;?/title><link>http://www.2676208.com/jinq0123/archive/2018/07/22/215796.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Sun, 22 Jul 2018 03:14:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/07/22/215796.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215796.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/07/22/215796.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215796.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215796.html</trackback:ping><description><![CDATA[<div>k8s闆嗙兢澶杇o瀹?#37812;?#32468;?#32448;?#28186;?br /><br />(閲戝簡鐨勪笓鏍?2018.7)<br /><br />闆嗙兢鍐?#28729;?#37812;?#32468;?#38343;瑕?#37813;撳寘鎴恉ocker闀滃儚锛?#28051;?#28028;?#38336;滃儚锛岀劧鍚庣敤 kubectl run 杩?#29723;?#38171;?br />杩?#29781;?#29825;?#32515;敤鎴?#29785;掕壊锛屽お楹荤儲锛?#26473;樻槸?#25956;闆嗙兢澶?#28729;?#37812;?#32468;祴璇?#23011;?#26440;冩柟渚?#37510;?br /><br />瀹?#37812;?#32468;?#25652;?#28003;跨敤 ericchiang/k8s, 姣?#28729;樻柟鐨?client-go 瑕佺畝鍗?#29825;?#28598;?#37510;?br /><br />闆嗙兢鍐?#28729;?#37812;?#32468;?#28003;跨敤`k8s.NewInClusterClient()`鍒涘缓锛?br />闆嗙兢澶?#28729;?#37812;?#32468;?#28003;跨敤 `NewClient(config *Config)`, 闇瑕佽緭鍏?#38320;嶇疆锛?br />閰嶇疆灏辨槸浠?~/.kube/config 璇?#37721;?#37928;?#37510;?br />鍙?#38000;?https://github.com/ericchiang/k8s/issues/79<br /><br />浠g爜濡?#28051;?#38171;?br /><br /><span style="font-family: Courier; color: #800000;">package main</span><br /><br /><span style="font-family: Courier; color: #800000;">import (</span><br /><span style="font-family: Courier; color: #800000;">    "context"</span><br /><span style="font-family: Courier; color: #800000;">    "fmt"</span><br /><span style="font-family: Courier; color: #800000;">    "log"</span><br /><span style="font-family: Courier; color: #800000;">    "io/ioutil"</span><br /><br /><span style="font-family: Courier; color: #800000;">    "github.com/ghodss/yaml"</span><br /><span style="font-family: Courier; color: #800000;">    "github.com/ericchiang/k8s"</span><br /><span style="font-family: Courier; color: #800000;">    corev1 "github.com/ericchiang/k8s/apis/core/v1"</span><br /><span style="font-family: Courier; color: #800000;">)</span><br /><br /><span style="font-family: Courier; color: #800000;">func main() {</span><br /><span style="font-family: Courier; color: #800000;">    data, err := ioutil.ReadFile("config")</span><br /><span style="font-family: Courier; color: #800000;">    if err != nil {</span><br /><span style="font-family: Courier; color: #800000;">        panic(err)</span><br /><span style="font-family: Courier; color: #800000;">    }</span><br /><br /><span style="font-family: Courier; color: #800000;">    // Unmarshal YAML into a Kubernetes config object.</span><br /><span style="font-family: Courier; color: #800000;">    var config k8s.Config</span><br /><span style="font-family: Courier; color: #800000;">    if err := yaml.Unmarshal(data, &config); err != nil {</span><br /><span style="font-family: Courier; color: #800000;">        panic(err)</span><br /><span style="font-family: Courier; color: #800000;">    }</span><br /><br /><span style="font-family: Courier; color: #800000;">    client, err := k8s.NewClient(&config)</span><br /><span style="font-family: Courier; color: #800000;">    // client, err := k8s.NewInClusterClient()</span><br /><span style="font-family: Courier; color: #800000;">    if err != nil {</span><br /><span style="font-family: Courier; color: #800000;">        log.Fatal(err)</span><br /><span style="font-family: Courier; color: #800000;">    }</span><br /><br /><span style="font-family: Courier; color: #800000;">    var nodes corev1.NodeList</span><br /><span style="font-family: Courier; color: #800000;">    if err := client.List(context.Background(), "", &nodes); err != nil {</span><br /><span style="font-family: Courier; color: #800000;">        log.Fatal(err)</span><br /><span style="font-family: Courier; color: #800000;">    }</span><br /><span style="font-family: Courier; color: #800000;">    for _, node := range nodes.Items {</span><br /><span style="font-family: Courier; color: #800000;">        fmt.Printf("name=%q schedulable=%t\n", *node.Metadata.Name, !*node.Spec.Unschedulable)</span><br /><span style="font-family: Courier; color: #800000;">    }</span><br /><span style="font-family: Courier; color: #800000;">}</span><br /><br />yaml 搴撶敤?#31777; ghodss/yaml锛屼笉?#20824;?#25956; go-yaml, ?#31497;?#21159;?#23012;閿?br />`yaml: unmarshal errors`<br />瑙?#38171;歨ttps://github.com/ericchiang/k8s/issues/81<br /><br />澶嶅埗 .kube/config 鍒?#26473;?#29723;?#37929;綍锛?#26473;?#29723;屽垪鍑?#37813;鏈夎妭鐐?#38171;?br /><br /><span style="font-family: Courier; color: #0000ff;">[jinqing@host-10-1-2-19 out-cluster]$ cp ~/.kube/config .</span><br /><span style="font-family: Courier; color: #0000ff;">[jinqing@host-10-1-2-19 out-cluster]$ ./out-cluster </span><br /><span style="font-family: Courier; color: #0000ff;">name="host-10-1-2-20" schedulable=true</span><br /><span style="font-family: Courier; color: #0000ff;">name="host-10-1-2-21" schedulable=true</span><br /><span style="font-family: Courier; color: #0000ff;">name="host-10-1-2-22" schedulable=true</span><br /><span style="font-family: Courier; color: #0000ff;">name="host-10-1-2-19" schedulable=true</span></div><div><span style="font-family: Courier; color: #0000ff;"><div><span style="font-family: Courier; color: #0000ff;">name="host-10-1-2-18" schedulable=true</span></div></span></div><img src ="http://www.2676208.com/jinq0123/aggbug/215796.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-07-22 11:14 <a href="http://www.2676208.com/jinq0123/archive/2018/07/22/215796.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>kubernetes瀵?#37713;?#37832;夌?#33333;?#37832;嶅姟http://www.2676208.com/jinq0123/archive/2018/07/14/215783.html閲戝簡閲戝簡Sat, 14 Jul 2018 03:43:00 GMThttp://www.2676208.com/jinq0123/archive/2018/07/14/215783.htmlhttp://www.2676208.com/jinq0123/comments/215783.htmlhttp://www.2676208.com/jinq0123/archive/2018/07/14/215783.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215783.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215783.htmlkubernetes瀵?#37713;?#37832;夌?#33333;?#37832;嶅姟

(閲戝簡鐨勪笓鏍?2018.7)

缃戞父鏈嶅姟?#27346;涓?#37928;?#37812;块棿鏈嶅姟?#27346;?#27128;鏈夌?#33333;?#37832;嶅姟?#27346;锛屽彲浠ョ敤 kubernetes statefulset 寮鍚?#28598;?#28051;?#28729;?#28186;?#37510;?br />
涓轰簡璁?#28729;?#37812;?#32468;兘澶?#37929;?#26473;?#37812;块棿鏈嶅姟?#27346;锛?#38340;や簡 statefulset 瑕佹眰鐨?headless 鏈嶅姟锛?br />杩橀』涓?#23011;?#28051;?#28729;?#28186;?#37714;涘缓 NodePort ?#34987;鍨?#37928;?#37832;嶅姟, ?#33503;涓?#38315;夋嫨Pod鍜岀姝㈣浆鍙?#37510;?br />
涓嬮潰 bootcamp.yml 鍏?#37714;涘?#36720;簡 bootcamp headless 鏈嶅姟(clusterIP: None),
鍙?#37714;涘?#36720;簡 bootcamp StatefulSet, 瀹?#28186;?#28051;暟涓?2.
?#21159;鍚?#37714;涘缓 bootcamp-0,1,2 鏈嶅姟锛屽垎鍒?#28725;瑰簲 bootcamp-0,1,2 pod.

鏈嶅姟涓?#37825;板ぇ浜?#28729;?#28186;?#28051;暟锛屾槸鎯虫祴璇?#28051;?#37832;嶅姟?#30149;鏈夊?#29808;簲鐨?#28729;?#28186;嬫椂鐨勮〃?#24135;銆?br />
缃戞父涓?#37928;?#37718;归厤鏈嶅姟?#27346;灏?#37714;嗛厤涓涓?#37812;块棿缁?#28729;?#37812;?#32468;?#38171;屽垪涓?bootcamp-0,1,2 pod 鎵鍦ㄨ妭鐐?#37928;?#28598;?#32515;?IP,
杩?#37722;屽?#29808;簲鏈嶅姟鐨?#32468;?#37721;?#38171;屽彂閫佺粰瀹?#37812;?#32468;?#38171;?#29825;?#28729;?#37812;?#32468;?#37929;?#26473;?#37510;?br />
[jinqing@host-10-240-79-10 statefulset]$ cat bootcamp.yml
apiVersion: v1
kind: Service
metadata:
  name: bootcamp
  namespace: jq
  labels:
    name: bootcamp
spec:
  ports:
    - port: 8080
  clusterIP: None  # StatefulSet瑕佹眰Headless鏈嶅姟
  selector:
    app: bootcamp  # 閫夋嫨 bootcamp 搴旂敤

---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: bootcamp
  namespace: jq
spec:
  serviceName: bootcamp  # 涓婇潰鐨?Headless 鏈嶅姟鍚?/span>
  replicas: 2
  template:
    metadata:
      labels:
        app: bootcamp  # 搴旂敤鍚?#38171;?#28051;?#37832;嶅姟涓?#37928;?selector 瀵瑰簲
    spec:
      containers:
      - name: bootcamp
        image: docker.io/jocatalin/kubernetes-bootcamp:v1

---
kind: Service
apiVersion: v1
metadata:
  name: bootcamp-0
  namespace: jq
spec:
  type: NodePort  # 瀵?#28598;?#37832;嶅姟
  externalTrafficPolicy: Local  # ?#31497;瑕佽浆鍙戝?#26495;叾浠栬妭鐐?/span>
  selector:
    app: bootcamp
    statefulset.kubernetes.io/pod-name: bootcamp-0  # 閫夋嫨 pod
  ports:
  - protocol: TCP
    nodePort: 30880  # 瀵?#28598;?#32468;?#37721;?/span>
    port: 8080
---
kind: Service
apiVersion: v1
metadata:
  name: bootcamp-1
  namespace: jq
spec:
  type: NodePort
  externalTrafficPolicy: Local
  selector:
    app: bootcamp
    statefulset.kubernetes.io/pod-name: bootcamp-1
  ports:
  - protocol: TCP
    nodePort: 30881
    port: 8080
---
kind: Service
apiVersion: v1
metadata:
  name: bootcamp-2
  namespace: jq
spec:
  type: NodePort
  externalTrafficPolicy: Local
  selector:
    app: bootcamp
    statefulset.kubernetes.io/pod-name: bootcamp-2
  ports:
  - protocol: TCP
    nodePort: 30882
    port: 8080

鍥?#28051;?statefulset 鐨勬瘡涓?#28729;?#28186;?#37832;変笉鍚?#37928;?#37837;?#32475;?#38171;?#37813;浠ュ彲浠?#28051;?#37832;嶅姟閫夋嫨涓涓?#28729;?#28186;?#37510;?br />
鍒╃敤 externalTrafficPolicy: Local 璁?#32515;?#37833;?#32450;?#23005;㈣浆鍙?#37510;?br />鍙?#38000;?service.spec.externalTrafficPolicy 鐨?#29831;存槑锛?br />
https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-type-nodeport

Setting service.spec.externalTrafficPolicy to the value Local will only proxy requests to local endpoints, never forwarding traffic to other nodes and thereby preserving the original source IP address. If there are no local endpoints, packets sent to the node are dropped, ...

鍥?#28051;?#37832;夊彲?#20824;澶?#28051;狿od寮鍦?#37722;?#28051;?#22957;鐐?#28051;?#38171;?#37813;浠?#28725;?#28598;?#32468;?#37721;?#29825;?#37812;愪簡?#31497;鍚?#37928;?30880-30882銆?br />濡傛灉闄?#37714;?#23011;?#28051;妭鐐?#37721;?#23534;涓涓?#28729;?#28186;?#38171;屽垯瀵?#28598;?#32468;?#37721;e彲浠?#29825;?#37812;愬悓涓涓?#37510;?br />
鍒涘缓鏈嶅姟锛?br />
[jinqing@host-10-240-79-10 statefulset]$ kubectl apply -f bootcamp.yml
service "bootcamp" created
statefulset.apps "bootcamp" created
service "bootcamp-0" created
service "bootcamp-1" created
service "bootcamp-2" created

鏈嶅姟濡?#28051;?#38171;?br />
[jinqing@host-10-240-79-10 statefulset]$ kubectl get service -n jq
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
bootcamp     ClusterIP   None             <none>        8080/TCP         3m
bootcamp-0   NodePort    10.96.128.137    <none>        8080:30880/TCP   3m
bootcamp-1   NodePort    10.109.2.56      <none>        8080:30881/TCP   3m
bootcamp-2   NodePort    10.102.181.193   <none>        8080:30882/TCP   3m

2涓?#28729;?#28186;?#38171;?br />
[jinqing@host-10-240-79-10 statefulset]$ kubectl get pod -n jq -o wide
NAME         READY     STATUS    RESTARTS   AGE       IP            NODE
bootcamp-0   1/1       Running   0          4m        10.244.0.42   host-10-240-79-10
bootcamp-1   1/1       Running   0          4m        10.244.1.63   host-10-240-79-11

璁块棶鏈嶅姟蹇?#26916;?#37816;囧畾?#22957;鐐?#38171;屼笉?#32048;鑷?#37716;ㄨ浆鍙?#38171;?br />
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.10:30880
Hello Kubernetes bootcamp! | Running on: bootcamp-0 | v=1
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.10:30881
curl: (7) Failed connect to 10.240.79.10:30881; Connection timed out
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30880
curl: (7) Failed connect to 10.240.79.11:30880; Connection timed out
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881
Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1

?#30149;鏈夎?#29115;浇鍧?#29723;?#38171;?0881绔?#37721;?#37804;绘槸璁块棶 bootcamp-1锛?br />
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881
Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881
Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881
Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881
Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881
Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1

涔熷彲浠?#28000;?#28598;?#32515;?#29825;块棶.

30882 绔?#37721;f棤娉?#26473;?#37818;?#38171;?br />
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30882
curl: (7) Failed connect to 10.240.79.11:30882; Connection refused
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.10:30882
curl: (7) Failed connect to 10.240.79.10:30882; Connection refused

3涓?#32468;?#37721;i兘鏈?#37929;戝惉锛?br />
[root@host-10-240-79-11 tmp]# netstat -ntl | grep 3088
tcp6       0      0 :::30881                :::*                    LISTEN     
tcp6       0      0 :::30882                :::*                    LISTEN     
tcp6       0      0 :::30880                :::*                    LISTEN     

iptables-save 杈撳?#21700;涓? 鍏?#28051;?10.244?#27128;Pod鐨?#32515;戞銆?br />
?#30149;鏈?#28729;?#28186;?#26473;?#29723;?#37928;勮妭鐐?#28051;?#38171;屼細涓?#23534;?#29831;锋眰锛?br />
-A KUBE-NODEPORTS -s 127.0.0.0/8 -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-MARK-MASQ
-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-XLB-LJXDQ4W47M42IZBH
-A KUBE-NODEPORTS -s 127.0.0.0/8 -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-MARK-MASQ
-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-XLB-U5NEOQT6R5WSBVOH

-A KUBE-XLB-LJXDQ4W47M42IZBH -s 10.244.0.0/16 -m comment --comment "Redirect pods trying to reach external loadbalancer VIP to clusterIP" -j KUBE-SVC-LJXDQ4W47M42IZBH
-A KUBE-XLB-LJXDQ4W47M42IZBH -m comment --comment "jq/bootcamp-1: has no local endpoints" -j KUBE-MARK-DROP
-A KUBE-XLB-U5NEOQT6R5WSBVOH -s 10.244.0.0/16 -m comment --comment "Redirect pods trying to reach external loadbalancer VIP to clusterIP" -j KUBE-SVC-U5NEOQT6R5WSBVOH
-A KUBE-XLB-U5NEOQT6R5WSBVOH -m comment --comment "jq/bootcamp-0: has no local endpoints" -j KUBE-MARK-DROP

鏈?#28729;?#28186;?#26473;?#29723;?#37928;勮妭鐐?#28051;婁細?#27974;鍙戠粰 Pod 8080锛?br />
-A KUBE-NODEPORTS -s 127.0.0.0/8 -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-MARK-MASQ
-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-XLB-U5NEOQT6R5WSBVOH
-A KUBE-NODEPORTS -s 127.0.0.0/8 -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-MARK-MASQ
-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-XLB-LJXDQ4W47M42IZBH

-A KUBE-XLB-LJXDQ4W47M42IZBH -s 10.244.0.0/16 -m comment --comment "Redirect pods trying to reach external loadbalancer VIP to clusterIP" -j KUBE-SVC-LJXDQ4W47M42IZBH
-A KUBE-XLB-LJXDQ4W47M42IZBH -m comment --comment "Balancing rule 0 for jq/bootcamp-1:" -j KUBE-SEP-LJQA4WUIKJUQ5ALU
-A KUBE-XLB-U5NEOQT6R5WSBVOH -s 10.244.0.0/16 -m comment --comment "Redirect pods trying to reach external loadbalancer VIP to clusterIP" -j KUBE-SVC-U5NEOQT6R5WSBVOH
-A KUBE-XLB-U5NEOQT6R5WSBVOH -m comment --comment "jq/bootcamp-0: has no local endpoints" -j KUBE-MARK-DROP

-A KUBE-SEP-LJQA4WUIKJUQ5ALU -s 10.244.1.63/32 -m comment --comment "jq/bootcamp-1:" -j KUBE-MARK-MASQ
-A KUBE-SEP-LJQA4WUIKJUQ5ALU -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp -j DNAT --to-destination 10.244.1.63:8080

30882 绔?#37721;f棤娉?#26473;?#37818;?br />-A KUBE-EXTERNAL-SERVICES -p tcp -m comment --comment "jq/bootcamp-2: has no endpoints" -m addrtype --dst-type LOCAL -m tcp --dport 30882 -j REJECT --reject-with icmp-port-unreachable

?#31092;璇?#28051;?#37813;?#28729;?#38171;?br />
[jinqing@host-10-240-79-10 statefulset]$ kubectl get statefulset -n jq
NAME       DESIRED   CURRENT   AGE
bootcamp   2         2         45m
[jinqing@host-10-240-79-10 statefulset]$ kubectl scale --replicas=3 statefulset/bootcamp -n jq
statefulset.apps "bootcamp" scaled
[jinqing@host-10-240-79-10 statefulset]$ kubectl get statefulset -n jq
NAME       DESIRED   CURRENT   AGE
bootcamp   3         3         47m
[jinqing@host-10-240-79-10 statefulset]$ kubectl get pod -n jq -o wide
NAME         READY     STATUS    RESTARTS   AGE       IP            NODE
bootcamp-0   1/1       Running   0          48m       10.244.0.42   host-10-240-79-10
bootcamp-1   1/1       Running   0          48m       10.244.1.63   host-10-240-79-11
bootcamp-2   1/1       Running   0          45s       10.244.2.60   host-10-240-79-12
[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.12:30882
Hello Kubernetes bootcamp! | Running on: bootcamp-2 | v=1


閲戝簡 2018-07-14 11:43 鍙戣〃璇?#29825;?/a>
]]>?#25956;鐩綍?#31912;鏋勮〃绀篻o鍖?#28186;?#29863;?#37711;崇郴http://www.2676208.com/jinq0123/archive/2018/06/25/215743.html閲戝簡閲戝簡Mon, 25 Jun 2018 09:16:00 GMThttp://www.2676208.com/jinq0123/archive/2018/06/25/215743.htmlhttp://www.2676208.com/jinq0123/comments/215743.htmlhttp://www.2676208.com/jinq0123/archive/2018/06/25/215743.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215743.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215743.html?#25956;鐩綍?#31912;鏋勮〃绀篻o鍖?#28186;?#29863;?#37711;崇郴

(閲戝簡鐨勪笓鏍?2018.6)

?#25011;鑷?#38171;?br />https://www.ardanlabs.com/blog/2017/02/package-oriented-design.html

If a package wants to import another package at the same level:

* Question the current design choices of these packages.
* If reasonable, move the package inside the source tree for the package that wants to import it.
* Use the source tree to show the dependency relationships.


閲戝簡 2018-06-25 17:16 鍙戣〃璇?#29825;?/a>
]]>Golang鐨?#37718;?#37722;?/title><link>http://www.2676208.com/jinq0123/archive/2018/06/25/215742.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Mon, 25 Jun 2018 08:51:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/06/25/215742.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215742.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/06/25/215742.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215742.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215742.html</trackback:ping><description><![CDATA[<div>Golang鐨?#37718;?#37722;?br /><br />(閲戝簡鐨勪笓鏍?2018.6)<br /><br />?#25011;鑷?#38171;?br /><br />https://talks.golang.org/2014/organizeio.slide#1<br /><br />The name of a package<br /><br />Keep package names short and meaningful.<br />Don't use underscores, they make package names long.<br /><br />    io/ioutil not io/util<br />    suffixarray not suffix_array<br /><br />Don't overgeneralize. A util package could be anything.<br /><br />The name of a package is part of its type and function names.<br />On its own, type Buffer is ambiguous. But users see:<br /><br />    buf := new(bytes.Buffer)<br /><br />Choose package names carefully.<br /><br />Choose good names for users.<br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/215742.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-06-25 16:51 <a href="http://www.2676208.com/jinq0123/archive/2018/06/25/215742.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>etcd+registrator+confd 鏈嶅姟鍙戠幇http://www.2676208.com/jinq0123/archive/2018/06/13/215722.html閲戝簡閲戝簡Wed, 13 Jun 2018 06:27:00 GMThttp://www.2676208.com/jinq0123/archive/2018/06/13/215722.htmlhttp://www.2676208.com/jinq0123/comments/215722.htmlhttp://www.2676208.com/jinq0123/archive/2018/06/13/215722.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215722.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215722.htmletcd+registrator+confd 鏈嶅姟鍙戠幇

(閲戝簡鐨勪笓鏍?2018.6)

鍥?#28051;簁8s浣跨敤 etcd, 鎵浠?#38315;?etcd 浣?#28051;?#37832;嶅姟鍙戠幇鐨?DB.

registrator ?#24434;浠?#28051;?docker ?#26591;寮?#26473;?#29723;?#37928;?#37832;嶅姟鑷?#37716;?#23049;ㄥ唽鍒?etcd.

confd 璇?#37721;?etcd, 鐢?#37812;?#38320;嶇疆鏂?#28000;?#37510;?br />
鍏?#26473;?#29723;?#28051;涓猠tcd?#25956;浜庢祴璇?#38171;?br />
docker run -d \
  -p 12379:2379 \
  --name jinqing-etcd \
  quay.io/coreos/etcd \
   /usr/local/bin/etcd \
  --listen-client-urls http://0.0.0.0:2379 \
  --advertise-client-urls http://0.0.0.0:12379

鍐?#26473;?#29723;?registrator:

docker run -d --rm \
    --name=jinqing-registrator \
    --net=host \
    --volume=/var/run/docker.sock:/tmp/docker.sock \
    gliderlabs/registrator:latest \
      -ip="192.168.93.183" \
      etcd://127.0.0.1:12379/registrator

濂藉儚鍙兘浣跨敤鏈?#37832;?#37928;?etcd. 涓鑸?#38343;瑕佺敤-ip鍙傛?#29256;寚?#30078;鏈?#37832;篒P銆?#23049;ㄥ唽鍒?registrator 鐩綍銆?br />
?#25956; etcdkeeper ?#24434;浠ユ煡鐪?#38007;?#37716;?#23049;ㄥ唽鐨?#37832;嶅姟銆俽egistrator ?#31497;鏀寔 etcd v3.

?#21159;鍚?#38320;嶇疆 confd

mkdir -p /etc/confd/{conf.d,templates}

/etc/confd/conf.d/myconfig.toml

[template]
src = "services.toml.tmpl"
dest = "/tmp/services.toml"
keys = [
    "/registrator",
]

/etc/confd/templates/services.toml.tmpl

[config]
{{- range lsdir "/registrator"}}
{{-     $serviceName := . }}
{{-     $serviceDir := printf "/registrator/%s/*" $serviceName }}

    [config.{{ $serviceName }}]
    # {{ $serviceDir }}

{{-     range gets $serviceDir }}
    {{ base .Key }} = {{ .Value }}
{{-     end }}

{{- end}}

# End of [config].

?#25956; lsdir 鍒?#37713;?#37813;鏈?#37832;嶅姟鐩綍锛岀劧鍚庣敤 gets 鍙?#37832;嶅姟鐩綍涓?#37928;勯敭鍊?#28725;?#37510;?br />
鎵?#29723;?confd:

~/go/bin/confd -onetime -backend etcd -node http://127.0.0.1:12379

[jinqing@localhost confd]$ cat /tmp/services.toml
[config]

    [config.etcd-2379]
    # /registrator/etcd-2379/*
    localhost.tech:jinqing-etcd:2379 = 192.168.93.183:12379

    [config.nginx]
    # /registrator/nginx/*
    localhost.tech:jinqing-nginx:80 = 192.168.93.183:1024

    [config.registry]
    # /registrator/registry/*
    localhost.tech:registry:5000 = 192.168.93.183:5000

# End of [config].


閲戝簡 2018-06-13 14:27 鍙戣〃璇?#29825;?/a>
]]>grpc-go涓巃ctor妯?#23534;?/title><link>http://www.2676208.com/jinq0123/archive/2018/06/12/215720.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Tue, 12 Jun 2018 03:15:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/06/12/215720.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215720.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/06/12/215720.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215720.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215720.html</trackback:ping><description><![CDATA[<div>grpc-go涓巃ctor妯?#23534;?br /><br />(閲戝簡鐨勪笓鏍?2018.6)<br /><br />grpc-go鏈嶅姟?#27346;鐨勬瘡涓?#29831;锋眰?#20824;鍦?#28051;涓嫭绔?#37928;?#37719;?#32459;?#28051;?#37813;?#29723;?#37510;?br />缃戞父鏈嶅姟?#27346;涓?#38171;?#28051;鑸?#29831;锋眰?#32048;璋冪敤?#29238;鎴?#37812;块棿鐨勬柟娉?#38171;?#38000;?#37812;块棿?#27128;涓涓嫭绔?#37928;?#37719;?#32459;?#37510;?br />?#24434;浠?#28751;嗘?#22359;?#26449;?#28853;幇涓篴ctor锛実rpc璇锋眰閫?#26473;嘋all()鎴朠ost()?#26591;娉?#37833;?#37813;?#29723;?#37510;?br />鍏?#28051;瑿all()?#32048;绛夊緟杩?#37733;?#38171;?#38000;孭ost()浼氬?#20635;鎵?#29723;屾棤杩?#37733;?#37706;?#37510;?br /><br /><span style="color: #800000; font-family: Courier;">type Room struct {</span><br /><span style="color: #800000; font-family: Courier;">    // actC ?#27128;鍏?#28000;?#37719;?#32459;嬪悜Room鍗?#32459;嬪彂閫?#37716;?#28003;?#37928;凜hannel锛?#37719;?#32459;?#28051;?#28751;?#28186;?#23046;?#37813;?#29723;屽姩浣?#37510;?/span><br /><span style="color: #800000; font-family: Courier;">    // Action 鍔?#28003;? ?#27128;?#26852;鍙傛?#29256;棤杩?#37733;?#37706;?#37928;勫?#33445;暟.</span><br /><span style="color: #800000; font-family: Courier;">    actC chan func()</span><br /><br /><span style="color: #800000; font-family: Courier;">    ...</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">// Run 杩?#29723;?#37812;块棿鍗?#32459;?</span><br /><span style="color: #800000; font-family: Courier;">func (r *Room) Run() {</span><br /><span style="color: #800000; font-family: Courier;">    ticker := time.NewTicker(20 * time.Millisecond)</span><br /><span style="color: #800000; font-family: Courier;">    defer ticker.Stop()</span><br /><br /><span style="color: #800000; font-family: Courier;">    for r.running {</span><br /><span style="color: #800000; font-family: Courier;">        select {</span><br /><span style="color: #800000; font-family: Courier;">        case act := <-r.actC:</span><br /><span style="color: #800000; font-family: Courier;">            act()</span><br /><span style="color: #800000; font-family: Courier;">        case <-ticker.C:</span><br /><span style="color: #800000; font-family: Courier;">            r.tick()</span><br /><span style="color: #800000; font-family: Courier;">        }</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">// Call calls a function f and returns the result.</span><br /><span style="color: #800000; font-family: Courier;">// f runs in the Room's goroutine.</span><br /><span style="color: #800000; font-family: Courier;">func (r *Room) Call(f func() interface{}) interface{} {</span><br /><span style="color: #800000; font-family: Courier;">    // ?#31912;鏋?#28000;巆h杩?#37733;?/span><br /><span style="color: #800000; font-family: Courier;">    ch := make(chan interface{}, 1)</span><br /><span style="color: #800000; font-family: Courier;">    r.actC <- func() {</span><br /><span style="color: #800000; font-family: Courier;">        ch <- f()</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><span style="color: #800000; font-family: Courier;">    // 绛夊緟鐩?#37714;?#26473;?#37733;炵粨鏋?/span><br /><span style="color: #800000; font-family: Courier;">    return <-ch</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">// Post 灏?#28051;涓?#37716;?#28003;?#37814;?#38315;?#37714;板唴閮?#37719;?#32459;?#28051;?#37813;?#29723;?</span><br /><span style="color: #800000; font-family: Courier;">func (r *Room) Post(f func()) {</span><br /><span style="color: #800000; font-family: Courier;">    r.actC <- f</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br />grpc鏈嶅姟?#26591;娉?#28641;?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">func (m *RoomService) Test(ctx context.Context, req *pb.TestReq) (*pb.TestResp, error) {</span><br /><span style="color: #800000; font-family: Courier;">    conn := conn_mgr.GetConn(ctx)</span><br /><span style="color: #800000; font-family: Courier;">    if conn == nil {</span><br /><span style="color: #800000; font-family: Courier;">        return nil, fmt.Errorf("can not find connection")</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><br /><span style="color: #800000; font-family: Courier;">    room := conn.GetRoom()</span><br /><span style="color: #800000; font-family: Courier;">    resp := room.Call(func() interface{} {</span><br /><span style="color: #800000; font-family: Courier;">        return room.Test(req)</span><br /><span style="color: #800000; font-family: Courier;">    })</span><br /><br /><span style="color: #800000; font-family: Courier;">    return resp.(*pb.TestResp), nil</span><br /><span style="color: #800000; font-family: Courier;">}</span></div><img src ="http://www.2676208.com/jinq0123/aggbug/215720.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-06-12 11:15 <a href="http://www.2676208.com/jinq0123/archive/2018/06/12/215720.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>?#25956; kubeadm --config 鍒涘缓 k8s 闆嗙兢http://www.2676208.com/jinq0123/archive/2018/05/27/215683.html閲戝簡閲戝簡Sun, 27 May 2018 11:22:00 GMThttp://www.2676208.com/jinq0123/archive/2018/05/27/215683.htmlhttp://www.2676208.com/jinq0123/comments/215683.htmlhttp://www.2676208.com/jinq0123/archive/2018/05/27/215683.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215683.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215683.html?#25956; kubeadm --config 鍒涘缓 k8s 闆嗙兢

(閲戝簡鐨勪笓鏍?2018.5)

鍒╃敤闃?#38322;屼簯鐨剏um闀滃?#24531;拰docker闀滃儚锛屽彲浠ヤ笉?#25956;浠?#37918;?#37929;?#37818;?#28729;夎鍒涘缓 k8s 闆嗙兢銆?br />
K8s 鐗?#37832;?#28051;?v1.10.3

鍙?#38000;?#38171;?br />
https://blog.csdn.net/u010209217/article/details/78533936
Kubernetes 1.7.5閮?#32515;?#28000;?#37721;妅ubernates-dashboard 1.7瀹夎

https://www.cnblogs.com/liangDream/p/7358847.html
CentOS7.3鍒╃敤kubeadm瀹夎kubernetes1.7.3瀹屾暣鐗?瀹樻柟鏂囨。濉?#37735;戠瘒)

https://yq.aliyun.com/articles/66474
闃?#38322;屼?#25117;揩閫?#38318;?#32515;睰ubernetes - VPC鐜?#28583;?

Docker ?#20961;瀹夎銆?br />
閲囩敤闃?#38322;屼簯鐨剏um婧?#38336;滃儚锛?#37929;?#37818;?#28729;夎:
yum -y install kubectl kubeadm kubelet

vi /etc/systemd/system/kubelet.service.d/10-kubeadm.conf, 涓簁ubelet?#22346;鍔?#28051;涓澶?#37928;?#37721;傛暟,
杩?#37837;穔ubelet灏变笉浼氬湪鍚?#37716;╬od鐨勬椂鍊欏?#35826;澶?#37928;刱8s浠撳?#25780;媺鍙杙ause-amd64:3.0闀滃儚?#31777;
--pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0

export KUBE_REPO_PREFIX 鐨勬柟寮?#37816;囧畾kube闀滃?#24531;?#25779;凡鍦?.8鐗?#37832;?#37722;庢棤鏁?#38171;?#38343;瑕?#37824;?#28051;?#38320;嶇疆鏂?#28000;?#28051;?#38320;嶇疆 imageRepository銆?br />
kubeadm.yaml 绀?#28186;?#38171;?br />https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/

apiVersion: kubeadm.k8s.io/v1alpha1
kind: MasterConfiguration
api:
  advertiseAddress: "10.20.79.10"
networking:
  podSubnet: "10.244.0.0/16"
kubernetesVersion: "v1.10.3"
imageRepository: "registry.cn-hangzhou.aliyuncs.com/google_containers"

鍒濆?#23338;寲鍛?#28000;?#28051;?#38171;?br />kubeadm init --config kubeadm.yaml

鍏?#28000;?#23049;?#37808;?#37904;?#38171;?br />
闇瑕?#23534;鍚?kubelet.service, ?#31497;?#21159;妫?#29025;?#32048;?#23012;璀?#37723;?#38171;?
systemctl enable kubelet && systemctl start kubelet
闇瑕?#37711;?#38338;?swap:
[ERROR Swap]: running with swap on is not supported. Please disable swap
swapoff -a

?#24434;浠ユ煡鐪?ls -ltr /etc/kubernetes/manifests/
yaml鏂?#28000;?#37714;楄〃锛屾瘡涓?#37826;?#28000;堕兘浼氬啓?#28483;闀滃儚鐨?#37734;板潃鍜岀増鏈?br />
[ERROR FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml]: /etc/kubernetes/manifests/kube-apiserver.yaml already exists
[ERROR Port-10250]: Port 10250 is in use
kubeadm?#32048;鑷?#37716;?#22955;?#29025;褰撳?#23943;幆澧冩槸鍚?#37832;?#28051;婃鍛?#28000;?#37813;?#29723;?#37928;?#8220;娈嬬暀”銆?#28641;傛灉鏈?蹇?#26916;?#23059;?#37918;?#37722;?#37712;嶈鎵?#29723;宨nit銆?#37812;?#28000;彲浠?#38315;?#26473;?#8221;kubeadm reset”鏉?#23059;?#37918;?#37916;?#28583;?浠?#28598;?#38322;嶆潵銆?br />
journalctl -xeu kubelet
?#25956;鏉ユ煡鐪媖ubelet鎵?#29723;?#37832;?#28000;涔?#38335;?#29831;?#37510;?br />
failed to run Kubelet: failed to create kubelet: misconfiguration: kubelet cgroup driver: "systemd" is different from docker cgroup driver: "cgroupfs"
闇瑕?#28103;?#37824;?/etc/systemd/system/kubelet.service.d/10-kubeadm.conf
sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
systemctl daemon-reload && systemctl restart kubelet


閲戝簡 2018-05-27 19:22 鍙戣〃璇?#29825;?/a>
]]>鎺ㄨ崘Golang鐨刟ssert搴?/title><link>http://www.2676208.com/jinq0123/archive/2018/05/14/215637.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Mon, 14 May 2018 02:42:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/05/14/215637.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215637.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/05/14/215637.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215637.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215637.html</trackback:ping><description><![CDATA[<div>鎺ㄨ崘Golang鐨刟ssert搴?br /><br />(閲戝簡鐨勪笓鏍?2018.5)<br /><br />https://github.com/aurelien-rainone/assertgo<br /><br />Conditionally compiled assertions in Go <br /><br />鍜孋++涓?#37928;刟ssert()涓鏍?#38171;?#26473;?#28051;槸甯?#37833;?#28000;?#32514;?#29831;?#37928;?#38171;屽繀椤?#28003;跨敤 debug 鎵嶈兘鍚敤銆?br /><br />濡?#38171;?br /><br />$ go run -tags debug main.go<br /><br />浣跨敤绀?#28186;?#38171;?br /><br />assert.True(true, "never printed")<br /><br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/215637.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-05-14 10:42 <a href="http://www.2676208.com/jinq0123/archive/2018/05/14/215637.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>consul鍛?#28000;?#28051;?#37928;勫嚑涓?#37734;板潃http://www.2676208.com/jinq0123/archive/2018/05/09/215627.html閲戝簡閲戝簡Wed, 09 May 2018 10:32:00 GMThttp://www.2676208.com/jinq0123/archive/2018/05/09/215627.htmlhttp://www.2676208.com/jinq0123/comments/215627.htmlhttp://www.2676208.com/jinq0123/archive/2018/05/09/215627.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215627.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215627.htmlconsul鍛?#28000;?#28051;?#37928;勫嚑涓?#37734;板潃

(閲戝簡鐨勪笓鏍?2018.5)

consul鍛?#28000;?#29723;?#28051;?#37832;?#28000;?#28051;嬪嚑涓?#37734;板潃鍙傛暟锛?br />
* -bind
    缁戝?#27692;?#26495;潃锛岀敤浜庨?#21977;兢閫氫俊锛岀己鐪?0.0.0.0
* -clint
    缁戝?#27692;?#26495;潃锛岀敤浜?RPC, DNS, HTTP and HTTPS锛岀己鐪?127.0.0.1
* -serf-lan-bind
    缁戝?#27692;?#26495;潃锛岀敤浜?#37712;?#32515;戦?#21977;兢閫氫俊锛岀己鐪?#28003;跨敤 -bind 鍦板潃
* -serf-wan-bind
    缁戝?#27692;?#26495;潃锛岀敤浜?#29882;?#37832;?#37812;?#38315;氫俊锛岀己鐪?#28003;跨敤 -bind 鍦板潃
* -advertise
    閫氬憡鍦板潃锛?#38315;氬憡缁?#38342;嗙兢涓?#37711;?#28000;栬妭鐐?#38171;岀己鐪?#28003;跨敤 -bind 鍦板潃
* -advertise-wan
    閫氬憡鍦板潃锛?#38315;氬憡缁?#37711;?#28000;?#37832;?#37812;?#37928;?#37832;嶅姟?#22957;鐐?#38171;岀己鐪?#28003;跨敤 -advertise 鍦板潃
* -join -retry-join
    鍔?#37711;?#38342;嗙兢鐨?#37929;?#37837;?#37734;板潃
* -join-wan -retry-join-wan
    璺?#37832;?#37812;块偊鑱?#37928;?#37929;?#37837;?#37734;板潃
* -recursor
    涓婃父DNS鍦板潃

瀹樻柟鏂囨。锛?https://www.consul.io/docs/agent/options.html#command-line-options


閲戝簡 2018-05-09 18:32 鍙戣〃璇?#29825;?/a>
]]>鏈嶅姟鍙戠幇鐨?#32513;勪欢http://www.2676208.com/jinq0123/archive/2018/05/04/215617.html閲戝簡閲戝簡Fri, 04 May 2018 08:07:00 GMThttp://www.2676208.com/jinq0123/archive/2018/05/04/215617.htmlhttp://www.2676208.com/jinq0123/comments/215617.htmlhttp://www.2676208.com/jinq0123/archive/2018/05/04/215617.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215617.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215617.html

鏈嶅姟鍙戠幇鐨?#32513;勪欢

(閲戝簡鐨勪笓鏍?2018.5)

鏈嶅姟鍙戠幇鏈?#28000;?#28051;嬬?#21226;欢锛?/p>

  • Service Registry 鏈嶅姟娉ㄥ唽涓?#36423;?/p>

    缁存姢鏈嶅姟鐨?#37714;楄〃锛屾彁渚涙煡璇?#37510;?#28051;鑸?#28729;炵幇涓?#37714;嗗竷寮?#38335;?#37706;?#28699;樺偍鏁版嵁搴?#37510;?/p>

  • Registrator 娉ㄥ唽?#27346;

    鐩戝惉鏈嶅姟鍒涘缓鍜屽垹闄?#27996;?#28000;?#38171;屽苟鍦?#37832;嶅姟娉ㄥ唽涓?#36423;?#37716;?#37804;?#23049;ㄥ唽鎴?#23049;?#38335;鏈嶅姟銆?/p>

  • Health Checker 鍋?#25652;锋?#29025;?#27346;

    鐩?#29785;?#37832;嶅姟?#27128;鍚?#37707;?#25652;?#38171;屽苟鍦?#37832;嶅姟娉ㄥ唽涓?#36423;?#37716;?#37804;?#37831;存柊鏈嶅姟銆?/p>

  • Load balancer 璐熻浇鍧?#29723;″櫒

    灏?#37832;嶅姟璇锋眰鍒嗘暎鍒板?#21226;釜鏈嶅姟?#27346;銆?/p>



閲戝簡 2018-05-04 16:07 鍙戣〃璇?#29825;?/a>
]]>Prometheus鍔?#37804;?#38320;嶇疆鐩?#37837;?/title><link>http://www.2676208.com/jinq0123/archive/2018/04/24/215601.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Tue, 24 Apr 2018 04:13:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/04/24/215601.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215601.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/04/24/215601.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215601.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215601.html</trackback:ping><description><![CDATA[<div>Prometheus鍔?#37804;?#38320;嶇疆鐩?#37837;?br /><br />(閲戝簡鐨勪笓鏍?2018.4)<br /><br />鏈绠鍗?#37928;勯?#23943;疆?#27128;闈?#37804;?#37929;?#37837;?#38171;?br /><br /><span style="color: #800000;">scrape_configs:</span><br /><span style="color: #800000;">  - job_name: 'prometheus'</span><br /><br /><span style="color: #800000;">    static_configs:</span><br /><span style="color: #800000;">      - targets: ['localhost:9090', 'localhost:9100']</span><br /><span style="color: #800000;">        labels:</span><br /><span style="color: #800000;">          group: 'prometheus'</span><br /><br />鏇?#37824;?#23005;?#37826;?#28000;?#37722;?#38171;屽彲浠?#37721;?#38315;?SIGHUP 瑙?#37721;?#38320;嶇疆閲嶆柊鍔?#26462;?#37510;?br /><br />Prometheus ?#24385;渚涗簡鏈嶅姟鍙戠幇鍔熻兘锛屽彲浠?#28000;?consul, dns, kubernetes, file 绛夌瓑澶氱?#23942;潵婧?#37721;戠?#29256;柊鐨?#37929;?#37837;?#37510;?br />鍏?#28051;?#37832;绠鍗?#37928;勬槸浠庢枃浠?#37721;戠幇鏈嶅姟銆?br /><br />渚嬪 /root/prometheus/prometheus.yml 閰嶇疆濡?#28051;?#38171;?br /><br /><span style="color: #800000;">global:</span><br /><span style="color: #800000;">  scrape_interval: 15s</span><br /><span style="color: #800000;">  evaluation_interval: 15s</span><br /><span style="color: #800000;">scrape_configs:</span><br /><span style="color: #800000;">  - job_name: 'prometheus'</span><br /><span style="color: #800000;">    static_configs:</span><br /><span style="color: #800000;">      - targets: ['127.0.0.1:9090', '127.0.0.1:9100']</span><br /><span style="color: #800000;">        labels:</span><br /><span style="color: #800000;">          group: 'prometheus'</span><br /><span style="color: #800000;">  - job_name: 'test'</span><br /><span style="color: #800000;">    file_sd_configs:</span><br /><span style="color: #800000;">      - files: ['/etc/prometheus/test_sd_config/*.yml']</span><br /><span style="color: #800000;">        refresh_interval: 5s</span><br /><br />?#25956; docker 鍚?#37716;?prometheus:<br /><br /><span style="color: #000080;">docker run -d --net=host \</span><br /><span style="color: #000080;">  -v /root/prometheus:/etc/prometheus \</span><br /><span style="color: #000080;">  --name prometheus-server \</span><br /><span style="color: #000080;">  prom/prometheus</span><br /><br />鍒涘缓 /root/prometheus/test_sd_config/test.yml 濡?#28051;?br /><br /><span style="color: #800000;">- targets: [ "192.168.93.192:8080" ]</span><br /><span style="color: #800000;">  labels:</span><br /><span style="color: #800000;">    group: "my_test_group"</span><br /><br />5s鍐?#28751;变細鑷?#37716;?#29831;?#37721;?test.yml ?#33503;?#22346;鍔?#37826;?#37928;?#37929;?#37837;?#37510;?br />?#24434;?#25956;娴?#29785;堝櫒鎵?#23534;Prometheus 9090 绔?#37721;? <br />?#29025;鐪?Status 涓?#37928;?Configuration, Targets, Service Discovery,<br />?#24434;浠?#37930;?#37714;版?#29256;坊鍔?#37928;?#37929;?#37837;?#37510;?br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/215601.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-04-24 12:13 <a href="http://www.2676208.com/jinq0123/archive/2018/04/24/215601.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>Docker杩?#29723;孭rometheus鍜孏rafanahttp://www.2676208.com/jinq0123/archive/2018/04/19/215597.html閲戝簡閲戝簡Thu, 19 Apr 2018 05:52:00 GMThttp://www.2676208.com/jinq0123/archive/2018/04/19/215597.htmlhttp://www.2676208.com/jinq0123/comments/215597.htmlhttp://www.2676208.com/jinq0123/archive/2018/04/19/215597.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215597.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215597.htmlDocker杩?#29723;孭rometheus鍜孏rafana

(閲戝簡鐨勪笓鏍?2018.4)

Prometheus瀹?#32515;?#37928;?#26473;?#29723;?#32448;?#28186;嬫槸鐩?#37818;?#37813;?#29723;?#37510;?br />?#24434;浠?#37721;傜収 https://www.katacoda.com/ 鐨勬暀绋嬬敤Docker杩?#29723;孭rometheus鍜孏rafana.
鎼滅储 Grafana 鐨勬暀绋?#38171;?#26473;?#29723;屾楠?#28641;?#28051;?#38171;?br />
1. 缂栧啓 prometheus.yml

global:
  scrape_interval:     15s
  evaluation_interval: 15s
scrape_configs:
  - job_name: 'prometheus'

    static_configs:
      - targets: ['localhost:9090', 'localhost:9100']
        labels:
          group: 'prometheus'

localhost 濂藉儚?#31497;琛?#38171;屾崲鎴?127.0.0.1
          
2. 杩?#29723;?prometheus

docker run -d --net=host \
  -v /root/prometheus.yml:/etc/prometheus/prometheus.yml \
  --name prometheus-server \
  prom/prometheus
 
3. 杩?#29723;?Node Exporter

docker run -d -p 9100:9100 \
-v "/proc:/host/proc" \
-v "/sys:/host/sys" \
-v "/:/rootfs" \
--net="host" \
--name=prometheus \
quay.io/prometheus/node-exporter:v0.13.0 \
  -collector.procfs /host/proc \
  -collector.sysfs /host/sys \
  -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"

4. 杩?#29723;?Grafana
 
  docker run -d --name=grafana -p 3000:3000 grafana/grafana
 
缂?#37930;佺敤鎴?#38171;?admin/admin

5. ?#22346;鍔?#37825;版嵁婧?#38171;屽苟瀵?#37711;?#28000;?#29723;?#37929;?br />
Add Data Sources ->
Name: Prometheus
Type: Prometheus
URL: http://1.2.3.4:9090
Access: proxy
Save & Test...

Create Import ->
Grafana.com Dashboard: 22





閲戝簡 2018-04-19 13:52 鍙戣〃璇?#29825;?/a>
]]>grpc-lua 绀?#28186;?/title><link>http://www.2676208.com/jinq0123/archive/2018/04/13/215587.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Fri, 13 Apr 2018 07:41:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/04/13/215587.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215587.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/04/13/215587.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215587.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215587.html</trackback:ping><description><![CDATA[<div>grpc-lua 绀?#28186;?br /><br />(閲戝簡鐨勪笓鏍?2018.4)<br /><br />grpc-lua (https://github.com/jinq0123/grpc-lua) ?#27128; grpc 鐨?lua 缁戝?#27692;簱锛?br />搴旂敤?#31777; luapbintf , ?#31497;闇瑕?#37922;?#37812;?#28000;g爜锛?#37929;?#37818;?#29831;?#37721;?proto 鏂?#28000;?#37510;?br /><br />濡?#38171;?br /><span style="color: #800000;">    -- Sync request.</span><br /><span style="color: #800000;">    local request = { name = "world" }</span><br /><span style="color: #800000;">    local response = assert(stub:sync_request("SayHello", request))</span><br /><span style="color: #800000;">    print("Greeter received: " .. response.message)</span><br /><br />瀹屾暣鐨?#32448;?#28186;?#28000;g爜瑙?examples 鐩綍銆?br /><br />鏈嶅姟?#27346;鍜屽鎴?#32468;兘鏀寔鍚屾鍜屽?#20635;璋冪敤銆?br /><br />灏?examples/conan_install.bat.example 鍘?#38340;?.example 鍚?#32514;锛岀劧鍚?#26473;?#29723;?#38171;?br />灏?#28729;夎鎵鏈?#37928;勪緷璧?#25652;? 椤?#37711;?#28729;夎 conan 鍖呯鐞嗗伐鍏?(http://docs.conan.io/en/latest/installation.html)銆?br />杩?#38343;瑕?#29825;?#32515;?git 浠?#37918;?#38171;屽洜涓?grpc 鐨勫?#24876;簱闇瑕佺炕杩?#28583;?#37510;?br /><br />conan_install.bat 瀹為檯涓婃槸涓嬭浇渚?#29863;?#25652;?#28000;g爜?#33503;缂?#29831;?#37510;傜粨鏋?#37734;ㄧ敤鎴?#37929;綍 .conan/data/銆?br />鍦?#37711;?#28051;?#37820;滅储 lua-cpp.exe, lua-cpp.dll, luapbintf.dll, grpc_lua.dll ?#33503;澶嶅埗鍒?examples/helloworld/ 鐩綍涓?#37510;?br /><br />?#21159;鍚?#37734;?helloworld 鐩綍涓?#37714;?#37714;?#26473;?#29723;?run_server.bat 鍜?run_client.bat ?#31092;璇?#37510;?br /><br /><div>?#20961;缂?#29831;戞祴璇曞彲琛?#37928;?#28729;屾?#26449;?#21613;彲涓嬭浇锛?br />grpc-lua 浠g爜鍙?#32448;?#28186;媁indows鎵?#29723;岀?#23338;簭锛歨ttps://download.csdn.net/download/jq0123/10346554<br />grpc-lua 绀?#28186;?CentOS 7.4 鎵?#29723;岀?#23338;簭鎵撳寘锛歨ttps://download.csdn.net/download/jq0123/10346003<br /><br />CentOS 7.4 瀹炴祴锛?br /><br /><span style="color: #0000ff;">[jinqing@localhost helloworld]$ ls</span><br /><span style="color: #0000ff;">greeter_client.lua   grpc_lua.so       lua-cpp         run_server.bat</span><br /><span style="color: #0000ff;">greeter_server.lua   helloworld.proto  luapbintf.so</span><br /><span style="color: #0000ff;">greeter_service.lua  liblua-cpp.so     run_client.bat</span><br /><span style="color: #0000ff;">[jinqing@localhost helloworld]$ ./lua-cpp greeter_server.lua</span><br /><span style="color: #0000ff;">Server listening on 0.0.0.0:50051</span><br /><span style="color: #0000ff;">Got hello from world</span><br /><span style="color: #0000ff;">Got hello from world</span><br /><br /><span style="color: #0000ff;">[jinqing@localhost helloworld]$ ./lua-cpp greeter_client.lua</span><br /><span style="color: #0000ff;">Greeter received: Hello world</span><br /><span style="color: #0000ff;">Async greeter received: Hello world</span><br /><span style="color: #0000ff;">[jinqing@localhost helloworld]$</span><br /><br /><span style="color: #0000ff;">[jinqing@localhost route_guide]$ ./lua-cpp route_guide_server.lua</span><br /><span style="color: #0000ff;">RecordRoute reader end.</span><br /><span style="color: #0000ff;">RouteChat reader end.</span><br /><br /><span style="color: #0000ff;">[jinqing@localhost route_guide]$ ./lua-cpp route_guide_client.lua</span><br /><span style="color: #0000ff;">-------------- Sync get feature --------------</span><br /><span style="color: #0000ff;">Found feature: {</span><br /><span style="color: #0000ff;">...</span><br /></div></div><img src ="http://www.2676208.com/jinq0123/aggbug/215587.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-04-13 15:41 <a href="http://www.2676208.com/jinq0123/archive/2018/04/13/215587.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>?#25956; DocFetcher 鍏?#37826;囨?#28357;储http://www.2676208.com/jinq0123/archive/2018/04/08/215577.html閲戝簡閲戝簡Sun, 08 Apr 2018 07:17:00 GMThttp://www.2676208.com/jinq0123/archive/2018/04/08/215577.htmlhttp://www.2676208.com/jinq0123/comments/215577.htmlhttp://www.2676208.com/jinq0123/archive/2018/04/08/215577.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215577.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215577.html?#25956; DocFetcher 鍏?#37826;囨?#28357;储

(閲戝簡鐨勪笓鏍?2018.4)

浠?#37715;嶇敤 Notepad++ 鐨?#37711;?#37826;囨?#28357;储锛屾病鏈夌储寮?#38171;屾?#24532;鎼滅储?#20824;椤?#32475;夊緟涓浼氬効銆?br />
鑰?DocFetcher ?#27128;寮婧?#37928;勬?#23684;潰鎼滅储搴旂敤锛屽?#21700;?#30028;储寮?#37722;?#38171;屾?#28357;储?#32048;绔?#37719;?#37713;虹粨鏋?#37510;?br />
鍏?#26916;?#28051;烘煇涓?#37929;綍鍒涘缓?#20648;寮?#38171;?#38315;夋嫨鏌?#27996;?#37722;?#32514;鍚?#37928;勬枃浠?#37510;傜劧鍚?#38315;?#28051;?#29831;ョ储寮?#26473;涜?#23678;?#28357;储銆?br />

閲戝簡 2018-04-08 15:17 鍙戣〃璇?#29825;?/a>
]]>缃戞父鏈嶅姟?#27346; Services-based 鍜?Cells-based 鏋?#37835;?/title><link>http://www.2676208.com/jinq0123/archive/2018/03/10/215551.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Sat, 10 Mar 2018 10:03:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/03/10/215551.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215551.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/03/10/215551.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215551.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215551.html</trackback:ping><description><![CDATA[<div>缃戞父鏈嶅姟?#27346; Services-based 鍜?Cells-based 鏋?#37835;?br /><br />(閲戝簡鐨勪笓鏍?2018.3)<br /><br />?#26852;缂?#28051;栫?#23680;?#25118;父鏈嶅姟?#27346;鏋?#37835;?#37928;?#29825;?#29825;?#37804;?#29882;?br />http://blog.csdn.net/SmartTony/article/details/6842065<br />鎻愬?#36720;簡2绉嶇?#25118;父鏈嶅姟?#27346;鏋?#37835;?#38171;?br /><br />* Services-based architecture 鍩轰簬鏈嶅姟鐨勬灦鏋?br />* Cells-based architecture 鍩轰簬cell鐨勬灦鏋?br /><br />鍩轰簬鏈嶅姟鐨勬灦鏋?#37816;?#37716;熻兘鍒?#37714;嗘垚?#31497;鍚?#37832;嶅姟锛屼笉鍚?#37832;嶅姟瀹炵幇浜庝笉鍚?#37928;?#26473;涚▼銆?br />鑰屽?#36720;簬cell鐨勬灦鏋勪?#36328;敤鐩?#37722;?#37928;凜ell杩涚?#23340;粍鎴?#28051;涓?#38342;嗙兢锛屾瘡涓狢ell杩涚?#23338;寘鍚?#37711;?#38318;?#37928;?#37716;熻兘銆?br /><br />鍩轰簬鏈嶅姟鐨勬灦鏋勪竴鐩存槸涓?#23092;?#37928;勬灦鏋?#38171;?#38007;?#28000;?microservice 鍜?service mesh 姒?#36423;?#37929;?#32513;?#23092;佽锛?br />鍩轰?#24225;井鏈嶅姟鐨勬灦鏋勫簲璇ヤ細鎴?#28051;?#37832;?#37833;?#37928;勬柟鍚?#37510;?br /><br />鍦ㄦ棤缂?#28598;?#37734;板浘缃戞父涓?#38171;屽簲璇ョ敤鍩轰簬cell鐨勬灦鏋勬潵瀹炵幇鍦板浘鍙?#37929;?#37711;?#37716;熻兘锛?br />鍏?#28000;?#28051;?#28003;嶇疆?#26852;鍏?#37928;?#37716;熻兘鍒欏簲璇?#28751;?#38322;?#37816;?#37832;嶅姟瀹炵幇銆?br />鑰?#38095;戝埌鏈嶅姟鏉?#37733;?#29835;冪敤寤舵椂杈?#28598;?#38171;屽浜?#28729;炴椂鎬?#23534;?#37928;?#37716;熻兘锛屽?#20414;K涔熷簲璇?#37734;╟ell涓?#28729;炵幇銆?br /><br />?#24434;浠?#38000;?#38095;戝鎴?#32468;?#38315;?#26473;囦笓闂?#37928;?#32515;戝叧鏉?#26473;?#37818;ell, 浣跨敤udp/kcp鏉?#37713;忓?#24532;椂寤?#37510;?br />鑰屽叾浠栭潪瀹炴椂鎬?#37832;嶅姟鐢盩cp缃戝?#23456;浆鍙?#37510;?br />鏈嶅姟?#27346;鍐?#38318;ㄥ彲鍏?#38318;?#32513;?#28051;閲囩敤 gRPC.<br /><br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/215551.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-03-10 18:03 <a href="http://www.2676208.com/jinq0123/archive/2018/03/10/215551.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>缃戞父鍚屾涓?#37928;勬椂?#26879;鎰?/title><link>http://www.2676208.com/jinq0123/archive/2018/01/18/215477.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Thu, 18 Jan 2018 13:28:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/01/18/215477.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215477.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/01/18/215477.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215477.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215477.html</trackback:ping><description><![CDATA[<div>缃戞父鍚屾涓?#37928;勬椂?#26879;鎰?br /><br />(閲戝簡鐨勪笓鏍?2018.1)<br /><br />?#26882;?#26879;?#29025;瑙?#38171;坱emporal perception锛?瀵?#28729;?#29785;傜幇?#34180;鐨勫欢缁?#37804;?#37724;岄?#21700;?#24532;?#37928;?#37721;嶅簲銆?#28729;為檯涓婃槸瀵?#27996;?#28000;?#37724;?#26473;?#37716;?#37928;勭煡瑙?#37510;?br />-- http://dict.youdao.com/w/temporal_perception<br /><br />缃戞父?#26882;?#26879;浠?#37832;嶅姟?#27346;鐨勪负鍑?#37510;?br />缃戞父瀹?#37812;?#32468;?#38016;?#37722;?#37832;嶅姟?#27346;渚嬪1甯ф椂?#26879;锛?#37813;浠?#29723;ㄧ幇鐨勬槸杩?#37720;?#37928;?#37734;烘櫙銆?br />鍥?#28051;?#37916;?#28729;?#38007;韩鐨勮涓烘槸?#20961;?#29025;鐨?#38171;?#37813;浠?#37832;?#37734;板彲浠ラ?#21228;祴鑷韩瑙掕壊鐨勭?#33333;?#38171;岃秴鍓嶄簬鍏?#28000;?#29785;掕壊銆?br />澶勪簬瓒?#37715;嶆椂?#26879;鐨勪富瑙?#28051;?#28598;勪簬杩?#37720;绘椂?#26879;鐨?#37711;?#28000;?#29785;掕壊鍏?#28598;?#37510;?br /><br />This raises the problem of interaction between objects displayed in present time space (the player's avatar) and objects displayed in a past time space (remote characters, AI entities). One solution is to make the LCT vary according to the distance from the player's avatar. This idea is called temporal perception, or presentation time or sometimes local perception filters and comes from the analogy with the appearance of the stars in the sky: the farther the distance, the longer the time the light takes to come to us [Singhal-Zyda].<br /><br />-- http://www.xlgps.com/article/99968.html 甯?#28729;?#38340;?#37714;?#28051;?#37928;?#29785;?#29785;?#28729;?#28003;撳?#28852;?#28028;犳挱<br /><br />涓?#29785;掑彲浠?#28051;?#26473;?#37720;绘椂?#26879;鐨?#37711;?#28000;?#29785;掕壊浜?#27996;?#38171;岃窛绂昏秺杩?#38171;屽彲浠?#37711;?#29825;?#37928;勬粸鍚庢椂闂村氨瓒?#38336;?#37510;?br />杩?#28051;?#22994;?#36423;?#32457;?#28003;滄椂?#26879;鎰熺煡杩囨护?#27346;(temporal perception filter)锛?br />鎴?#38000;?#37832;?#37734;版?#29114;煡杩囨护?#27346;(local perception filter)銆?br /><br />?#24434;浠ョ敤鏄熸槦浣滅被姣?#38171;?#37812;?#28000;?#37930;?#37714;?#37928;勪竴鍏夊勾杩?#37928;?#37828;熸槦鍏?#28729;炴槸涓骞村墠鐨?#37828;熸槦銆?br /><br />Local Perception Filter Demo<br />http://mikolalysenko.github.io/local-perception-filter-demo/<br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/215477.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-01-18 21:28 <a href="http://www.2676208.com/jinq0123/archive/2018/01/18/215477.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>涓?LiteIDE ?#22346;鍔?#38315;?#28051;?#37837;?#29825;?/title><link>http://www.2676208.com/jinq0123/archive/2018/01/06/215458.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Sat, 06 Jan 2018 03:05:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2018/01/06/215458.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215458.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2018/01/06/215458.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215458.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215458.html</trackback:ping><description><![CDATA[<div>涓?LiteIDE ?#22346;鍔?#38315;?#28051;?#37837;?#29825;?br /><br />(閲戝簡鐨勪笓鏍?2018.1)<br /><br />"[Eclipse Mark Occurrences](http://www.eclipse.org/pdt/help/html/mark_occurrences.htm)"<br />?#24434;浠?#37734;?#23114;氬姩鏉?#37827;佽竟鏄?#32448;烘枃涓?#37813;鏈?#38315;?#28051;?#37928;?#37837;?#29825;?#38171;?br />?#24434;浠?#38315;?#28051;?#37836;?#28051;?#37721;?#38322;?#37828;?#32448;?#37832;?#28598;氬?#25117;?#26336;敤銆備笉杩?GoClipse ?#30149;鏈?"Mark Occurrences" 鍔熻兘銆?br />VS code 鏈夋鍔熻兘銆?br /><br />LiteIDE 瀵?#27996;巄uild閿?#29831;細鏄?#32448;?#26473;?#32457;?#37837;?#29825;?#38171;?#37813;浠?#37808;?#29785;夊彲浠?#28186;?#23005;?#28729;炵幇"Mark Occurrences"銆?br /><br />棣?#37711;?#37813;?#37714;颁簡鎵?#37837;?#29825;?#37928;?#37716;熻兘銆?#37837;?#29825;扮敤鍒伴?#22730;锛?#37813;浠?#37820;?QColor', 鎵?#37714;颁簡锛?br />```c++<br />QColor markTypeColor(LiteApi::EditorNaviagteType type)<br />```<br /><br />鐩?#37711;?#37928;?#37818;?#37721;d細?#25956;鍒?#38171;?br />```c++<br />    void insertNavigateMark(int line, LiteApi::EditorNaviagteType type, const QString &msg, const char* tag);<br />    void clearAllNavigateMark(LiteApi::EditorNaviagteType types, const char *tag);<br />```<br /><br />瀵?#37813;?#38315;?#28051;椂瑙?#37721;?#37837;?#29825;?#37928;勪唬?#29212;锛?#38315;?#28051;?#37812;栨?#28357;储?#26882;?#32048;鏈?#37734;?#29785;掓鍦?#37713;?#38171;屾悳"find", 鎵?#37714;?#38171;?br />```c++<br />if (!m_findExpression.isEmpty()) {<br />    if (!findInBlock(block,m_findExpression,pos,m_findFlags,cur)) {<br />        break;<br />    }<br />    ...<br />    painter.drawRoundedRect(offsetX+left,r.top()+l.y(),right-left,l.height(),3,3);<br />} else if (!m_selectionExpression.isEmpty()) {<br />    if (!findInBlock(block,m_selectionExpression,pos,QTextDocument::FindWholeWords,cur)) {<br />        break;<br />    }<br />    ...<br />    painter.drawRoundedRect(offsetX+left,r.top()+l.y(),right-left,l.height(),3,3);<br />}<br />```<br /><br />鍙戠幇鐢绘柟妗?#28000;?#37734;ㄥ彲瑙?#37718;哄煙銆?#32513;?#32513;ф煡鎵?m_findExpression 鍜?m_selectionExpression 鏇?#37824;?#28598;?#38171;?br />?#22346;鍔?'updateNavigateMarks()'<br /><br />```c++<br />void LiteEditorWidgetBase::setFindOption(LiteApi::FindOption *opt)<br />{<br />    ...<br />+   updateNavigateMarks(LiteApi::EditorNavigateFind);<br />    viewport()->update();<br />}<br />```<br /><br />```c++<br />void LiteEditorWidgetBase::slotSelectionChanged()<br />{<br />    ...<br />        m_selectionExpression.setPattern(pattern);<br />+       updateNavigateMarks(LiteApi::EditorNavigateSelection);<br />        viewport()->update();<br />    ...<br />}<br />```<br /><br />椤绘坊鍔?涓?#37826;?#37928;勭被鍨?#38171;?br />```c++<br />enum EditorNaviagteType{<br />    EditorNavigateNormal = 1,<br />    EditorNavigateWarning = 2,<br />    EditorNavigateError = 4,<br />    EditorNavigateReload = 8,<br />+   EditorNavigateFind = 16,<br />+   EditorNavigateSelection = 32,<br />    EditorNavigateBad = EditorNavigateWarning|EditorNavigateError<br />};<br />```<br /><br />鎼滅储 `EditorNavigateWarning`, 鎵?#37714;板洜鏂板?#28853;被鍨嬮』鏇?#37824;?#28028;?#37711;堢骇琛?#37724;岄?#22730;鍑芥暟銆?br /><br />```c++<br />const int PRIORITYLIST_LENGTH = 7;<br />const LiteApi::EditorNaviagteType MARKTYPE_PRIORITYLIST[PRIORITYLIST_LENGTH] = {<br />        ..., LiteApi::EditorNavigateFind, LiteApi::EditorNavigateSelection, ...<br />    };<br />...<br />inline QColor markTypeColor(LiteApi::EditorNaviagteType type) {<br />    switch(type) {<br />    ...<br />    case LiteApi::EditorNavigateNormal:<br />        return Qt::darkGreen;<br />    case LiteApi::EditorNavigateReload:<br />        return Qt::darkBlue;<br />    }<br />}<br />```<br /><br />鏇存柊鏍?#29825;版椂鍏堟竻绌?#38171;岀劧鍚?#38315;?#29723;屾?#28357;储?#22346;鍔?#37837;?#29825;?#38171;?br />```c++<br />// Update selections or find marks.<br />void LiteEditorWidgetBase::updateNavigateMarks(LiteApi::EditorNaviagteType type)<br />{<br />    clearAllNavigateMark(type, "");<br />    ...<br /><br />    QTextDocument *doc = this->document();<br />    for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next())<br />    {<br />        if (!needToMarkBlock(it, type))<br />            continue;<br />        int lineNumber = it.blockNumber() + 1;<br />        insertNavigateMark(lineNumber, type, QString("%1: %2").arg(lineNumber).arg(it.text()), "");<br />    }<br />}<br /><br />bool LiteEditorWidgetBase::needToMarkBlock(<br />    const QTextBlock &block, LiteApi::EditorNaviagteType type) const<br />{<br />    ...<br />    if (LiteApi::EditorNavigateFind == type)<br />        return findInBlock(block, m_findExpression, pos, m_findFlags, cur);<br />    if (LiteApi::EditorNavigateSelection == type)<br />        return findInBlock(block, m_selectionExpression, pos,<br />                           QTextDocument::FindWholeWords, cur);<br />    return false;<br />}<br />```<br /><br />?#20961;鍚堝苟涓诲共锛?br />```<br />Revision: 43f4954b0b802eccbbf451136be600bfcec71f27<br />Author: Jin Qing <jinq0123@163.com><br />Date: 18.1.5 19:08:26<br />Message:<br />Add "Mark Occurrences" function that marks selections and findings.<br /><br />----<br />Modified: liteidex/src/api/liteeditorapi/liteeditorapi.h<br />Modified: liteidex/src/plugins/liteeditor/liteeditorwidgetbase.cpp<br />Modified: liteidex/src/plugins/liteeditor/liteeditorwidgetbase.h<br />```</div><img src ="http://www.2676208.com/jinq0123/aggbug/215458.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2018-01-06 11:05 <a href="http://www.2676208.com/jinq0123/archive/2018/01/06/215458.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>gRPC-go 杩?#37818;?#32480;?#37918;?/title><link>http://www.2676208.com/jinq0123/archive/2017/12/25/215444.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Mon, 25 Dec 2017 11:00:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2017/12/25/215444.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215444.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2017/12/25/215444.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215444.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215444.html</trackback:ping><description><![CDATA[<div>gRPC-go 杩?#37818;?#32480;?#37918;?br /><br />(閲戝簡鐨勪笓鏍?2017.12)<br /><br />鎶?example greeter 鏀?#28051;涓?#38171;屽鐞?SayHello() 璇锋?#20635;椂锛屼笉浠?#28000;?#26473;?#37733;?#37832;?#23046;?#29831;锋眰鑰?#37928;?#37722;嶅瓧锛?br />杩?#26473;?#37733;?#28051;婃璇锋眰鐨?#37722;嶅瓧锛屽锛?br />```<br /><span style="color: #0000ff;">λ go run greeter_client/main.go</span><br /><span style="color: #0000ff;">2017/12/25 17:59:13 Greeting: Hello 'world' (prev '')</span><br /><span style="color: #0000ff;">2017/12/25 17:59:15 Greeting: Hello 'world2' (prev 'world')</span><br />```<br /><br />鍏?#28751;?#28729;?#37812;?#32468;?#37719;?#23046;?#29831;锋眰鏀?#28051;?#28598;氭璇锋眰锛?br /><br />```go<br /><span style="color: #800000; font-family: Courier;">    r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: name})</span><br /><span style="color: #800000; font-family: Courier;">    log.Printf("Greeting: %s", r.Message)</span><br /><span style="color: #800000; font-family: Courier;">    time.Sleep(2 * time.Second)</span><br /><br /><span style="color: #800000; font-family: Courier;">    r, err = c.SayHello(context.Background(), &pb.HelloRequest{Name: name + "2"})</span><br /><span style="color: #800000; font-family: Courier;">    log.Printf("Greeting: %s", r.Message)</span><br /><span style="color: #800000; font-family: Courier;">    ...</span><br />```<br /><br />鏈嶅姟?#27346;闇瑕?#28051;?#23011;?#28051;?#26473;?#37818;ヤ繚瀛?#37722;?#38007;?#37928;勬?#29256;嵁銆?#26473;?#37818;?#37714;涘?#28888;椂鍒濆?#23338;寲鏁版嵁锛?#26473;?#37818;?#37826;?#23534;?#26882;娓?#37918;嗘?#29256;嵁銆?br />杩?#38322;屽埄?#25956;?#31777;杩?#37818;?#32513;?#29825;?#37928;?#37818;?#37721;?#38171;屼笉?#29025;閬撴槸鍚︽槸鏈閫?#35120;?#37928;?#28729;?#37916;版柟寮?<br /><br />鏈嶅姟?#27346;鍒涘?#28888;椂?#22346;鍔?StatsHandler 閫?#26916;?#38171;?#26440;?#37711;?#28051;涓?stats.Handler 鐨?#28729;炵幇銆?br />```<br /><span style="color: #800000; font-family: Courier;">-    s := grpc.NewServer()</span><br /><span style="color: #800000; font-family: Courier;">+    s := grpc.NewServer(grpc.StatsHandler(&statshandler{}))</span><br />``` <br /><br />statshandler 闇瀹炵幇4涓柟娉?#38171;屽彧?#25956;鍒?涓?#26473;?#37818;?#37929;?#37711;?#37928;勬柟娉?#38171;孴agConn() 鍜?HandleConn(),<br />鍙?#28598;?涓?TagRPC() 鍜?HandleRPC() ?#25956;浜嶳PC缁?#29825;? 瀹炵幇涓?#32460;?#37510;?br /><br />```go<br /><span style="color: #800000; font-family: Courier;">type statshandler struct{}</span><br /><br /><span style="color: #800000; font-family: Courier;">// TagConn ?#25956;鏉?#32513;?#26473;?#37818;?#37813;?#28051;?#37837;?#32475;?#38171;?#28000;?#23005;?#37833;?#37837;?#29831;?#26473;?#37818;?瀹?#37734;ㄦ槸鎵句笉鍑?#26473;?#37832;?#28000;涔?#37716;?#23049;?#37833;?#37837;?#29831;?#26473;?#37818;?.</span><br /><span style="color: #800000; font-family: Courier;">// 杩?#28051;?#37837;?#32475;炬槸涓?#37816;?#38333;?#38171;屽彲?#32346;璇?#23011;?#28051;?#26473;?#37818;ュ敮涓銆?/span><br /><span style="color: #800000; font-family: Courier;">// 灏?#29831;?#37816;?#38333;堟坊鍔?#37714;?#28051;?#28051;嬫枃涓?#37720;?#38171;?#38335;?#28051;?connCtxKey{}.</span><br /><span style="color: #800000; font-family: Courier;">func (h *statshandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context {</span><br /><span style="color: #800000; font-family: Courier;">    return context.WithValue(ctx, connCtxKey{}, info)</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">// TagRPC 涓?#32460;?</span><br /><span style="color: #800000; font-family: Courier;">func (h *statshandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {</span><br /><span style="color: #800000; font-family: Courier;">    return ctx</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">// HandleConn 浼氬湪杩?#37818;?#23534;濮嬪?#23680;粨鏉熸椂琚?#29835;冪敤锛屽垎鍒細杈?#37711;ヤ笉鍚?#37928;勭?#33333;?</span><br /><span style="color: #800000; font-family: Courier;">func (h *statshandler) HandleConn(ctx context.Context, s stats.ConnStats) {</span><br /><span style="color: #800000; font-family: Courier;">    tag, ok := getConnTagFromContext(ctx)</span><br /><span style="color: #800000; font-family: Courier;">    if !ok {</span><br /><span style="color: #800000; font-family: Courier;">        log.Fatal("can not get conn tag")</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><br /><span style="color: #800000; font-family: Courier;">    connsMutex.Lock()</span><br /><span style="color: #800000; font-family: Courier;">    defer connsMutex.Unlock()</span><br /><br /><span style="color: #800000; font-family: Courier;">    switch s.(type) {</span><br /><span style="color: #800000; font-family: Courier;">    case *stats.ConnBegin:</span><br /><span style="color: #800000; font-family: Courier;">        conns[tag] = ""</span><br /><span style="color: #800000; font-family: Courier;">        log.Printf("begin conn, tag = (%p)%#v, now connections = %d\n", tag, tag, len(conns))</span><br /><span style="color: #800000; font-family: Courier;">    case *stats.ConnEnd:</span><br /><span style="color: #800000; font-family: Courier;">        delete(conns, tag)</span><br /><span style="color: #800000; font-family: Courier;">        log.Printf("end conn, tag = (%p)%#v, now connections = %d\n", tag, tag, len(conns))</span><br /><span style="color: #800000; font-family: Courier;">    default:</span><br /><span style="color: #800000; font-family: Courier;">        log.Printf("illegal ConnStats type\n")</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br /><span style="color: #800000; font-family: Courier;">// HandleRPC 涓?#32460;?</span><br /><span style="color: #800000; font-family: Courier;">func (h *statshandler) HandleRPC(ctx context.Context, s stats.RPCStats) {</span><br /><span style="color: #800000; font-family: Courier;">}</span><br />```<br /><br />?#25956;涓涓猰ap鏉?#32480;?#37918;嗘墍鏈?#26473;?#37818;?#38171;?#28000;?#26473;?#37818;?#37928;?#37837;?#32475;??#27128;涓?#37816;?#38333;?涓?#38335;?#38171;屽?#28051;?#28051;婃璇锋眰鑰?#37928;?#37722;嶅瓧銆?br />鍥?#28051;?#37832;?#28598;氱?#36328;▼璁块棶锛?#37813;鏈?#37716;?#28051;?Mutex 鏉ヤ繚鎶?#37510;?br />杩?#37818;ョ粨鏉熸椂锛屽皢浠?conns 涓?#37714;?#38340;?#26473;?#37818;?#37929;?#37711;?#37928;勬?#29256;嵁銆?br /><br />```go<br /><span style="color: #800000; font-family: Courier;">var connsMutex sync.Mutex</span><br /><span style="color: #800000; font-family: Courier;">var conns map[*stats.ConnTagInfo]string = make(map[*stats.ConnTagInfo]string)</span><br />```<br /><br />getConnTagFromContext() 浠?#28051;?#28051;嬫枃涓?#37721;?#26473;?#37818;?#37837;?#32475;?#38171;?br /><br />```go<br /><span style="color: #800000; font-family: Courier;">type connCtxKey struct{}</span><br /><br /><span style="color: #800000; font-family: Courier;">func getConnTagFromContext(ctx context.Context) (*stats.ConnTagInfo, bool) {</span><br /><span style="color: #800000; font-family: Courier;">    tag, ok := ctx.Value(connCtxKey{}).(*stats.ConnTagInfo)</span><br /><span style="color: #800000; font-family: Courier;">    return tag, ok</span><br /><span style="color: #800000; font-family: Courier;">}</span><br />```<br /><br />鏈鍚?#28751;?SayHello() 鏀?#28051;?#29825;板綍璇锋眰鑰?#37722;嶅瓧锛屽苟杩?#37733;?#28051;婃璇锋眰鑰?#37928;?#37722;嶅瓧銆?br /><br />```go<br /><span style="color: #800000; font-family: Courier;">func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {</span><br /><span style="color: #800000; font-family: Courier;">    tag, _ := getConnTagFromContext(ctx)</span><br /><span style="color: #800000; font-family: Courier;">    log.Printf("SayHello(), conn tag = (%p)%#v\n", tag, tag)</span><br /><br /><span style="color: #800000; font-family: Courier;">    connsMutex.Lock()</span><br /><span style="color: #800000; font-family: Courier;">    defer connsMutex.Unlock()</span><br /><span style="color: #800000; font-family: Courier;">    prev := conns[tag]</span><br /><span style="color: #800000; font-family: Courier;">    conns[tag] = in.Name</span><br /><br /><span style="color: #800000; font-family: Courier;">    return &pb.HelloReply{Message: fmt.Sprintf("Hello '%s' (prev '%s')", in.Name, prev)}, nil</span><br /><span style="color: #800000; font-family: Courier;">}</span><br />```<br /><br />?#31092;璇?#28598;?#28051;?#28729;?#37812;?#32468;?#26473;?#37818;?#38171;屽彲浠?#37930;?#37714;版瘡涓?#28729;?#37812;?#32468;?#37832;?#38007;繁鐨勭?#33333;?#38171;屼?#25485;笉褰卞搷銆?br /><br />```<br /><span style="color: #0000ff;">E:\Git\grpc-go\examples\helloworld (master)</span><br /><span style="color: #0000ff;">λ go run greeter_server/main.go</span><br /><span style="color: #0000ff;">2017/12/25 18:39:03 start</span><br /><span style="color: #0000ff;">2017/12/25 18:39:11 begin conn, tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}, now connections = 1</span><br /><span style="color: #0000ff;">2017/12/25 18:39:11 SayHello(), conn tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}</span><br /><span style="color: #0000ff;">2017/12/25 18:39:13 SayHello(), conn tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}</span><br /><span style="color: #0000ff;">2017/12/25 18:39:13 begin conn, tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}, now connections = 2</span><br /><span style="color: #0000ff;">2017/12/25 18:39:13 SayHello(), conn tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}</span><br /><span style="color: #0000ff;">2017/12/25 18:39:15 SayHello(), conn tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}</span><br /><span style="color: #0000ff;">2017/12/25 18:39:15 SayHello(), conn tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}</span><br /><span style="color: #0000ff;">2017/12/25 18:39:17 SayHello(), conn tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}</span><br /><span style="color: #0000ff;">2017/12/25 18:39:17 SayHello(), conn tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}</span><br /><span style="color: #0000ff;">2017/12/25 18:39:19 end conn, tag = (0xc042182040)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0420818f0), LocalAddr:(*net.TCPAddr)(0xc0420818c0)}, now connections = 1</span><br /><span style="color: #0000ff;">2017/12/25 18:39:19 SayHello(), conn tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}</span><br /><span style="color: #0000ff;">2017/12/25 18:39:21 end conn, tag = (0xc0421ae200)&stats.ConnTagInfo{RemoteAddr:(*net.TCPAddr)(0xc0421de060), LocalAddr:(*net.TCPAddr)(0xc0421de030)}, now connections = 0</span><br />```<br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/215444.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2017-12-25 19:00 <a href="http://www.2676208.com/jinq0123/archive/2017/12/25/215444.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>asio 鍗?#32459;?#28051;?yieldhttp://www.2676208.com/jinq0123/archive/2017/12/07/215397.html閲戝簡閲戝簡Thu, 07 Dec 2017 06:51:00 GMThttp://www.2676208.com/jinq0123/archive/2017/12/07/215397.htmlhttp://www.2676208.com/jinq0123/comments/215397.htmlhttp://www.2676208.com/jinq0123/archive/2017/12/07/215397.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215397.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215397.html

asio 鍗?#32459;?#28051;?yield


(閲戝簡鐨勪笓鏍?2017.12)


https://stackoverflow.com/questions/26127458/yielding-in-boost-asio-stackful-coroutine


Asio spawn() ?#24434;浠?#27996;?#37922;?#28051;涓?#37719;?#32459;?#38171;?#37719;?#32459;?#28051;彲浠?#29835;冪敤 async_read(..., yield), async_write(..., yield), 浣嗘槸?#31497;?#29025;閬撳浣?#28051;?#37716;?#38322;?#37824;?#37818;?#37714;?#37833;?yield)?


asio::spawn(strand_, [this, self](asio::yield_context yield)
{
    while (!computationFinished)
    {
        computeSomeMore();
        yield; // WHAT SHOULD THIS LINE BE?
    }
}


绛旀?#22559;槸锛?/p>

iosvc.post(yield);


鍏?#28000;?#26473;樺彲浠ユ槸

iosvc.poll_one();

iosvc.poll();


搴?#29831;ユ槸 post(yield) 鏈鍚?#38315;?#37510;?/p>


... polling the io_service avoids the context switch overhead, but unhandled exceptions from handlers will unwind and destroy the coroutine.




閲戝簡 2017-12-07 14:51 鍙戣〃璇?#29825;?/a>
]]>?#25956; Lile 鍒涘缓 gRPC-go 鏈嶅姟http://www.2676208.com/jinq0123/archive/2017/11/28/215377.html閲戝簡閲戝簡Tue, 28 Nov 2017 10:47:00 GMThttp://www.2676208.com/jinq0123/archive/2017/11/28/215377.htmlhttp://www.2676208.com/jinq0123/comments/215377.htmlhttp://www.2676208.com/jinq0123/archive/2017/11/28/215377.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215377.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215377.html?#25956; Lile 鍒涘缓 gRPC-go 鏈嶅姟

(閲戝簡鐨勪笓鏍?2017.11)

Lile ?#27128;涓涓?#23480;?#37711;?#38171;岀敤浜?Go 璇█蹇?#38315;?#37714;涘缓 gRPC 鏈嶅姟銆?br />https://github.com/lileio/lile

?#32048;鑷?#37716;ㄦ坊鍔?Prometheus, Zipkin 鍜?Google PubSub 鏀寔銆?br />
go get -u github.com/lileio/lile/...
灏?#28729;夎鎵鏈?#28186;?#29863;?#37718;?#38171;屽苟鐢?#37812;?bin/lile.exe, bin/protoc-gen-lile-server.exe.
鍙?#28598;?#26473;?#38343;瑕?#28729;夎 protoc.exe.

鎸夌収绀?#28186;?#37714;涘缓 users 鏈嶅姟锛?br />
E:\gopath\src\github.com
λ lile new jinq0123/users
Creating project in E:\gopath\src\github.com\jinq0123\users
Is this OK? [y]es/[n]o
y
.
├── server
│   ├── server.go
│   └── server_test.go
├── subscribers
│   └── subscribers.go
├── users
│   ├── cmd
│   │   ├── root.go
│   │   ├── serve.go
│   │   ├── subscribe.go
│   │   └── up.go
│   └── main.go
├── users.proto
├── Makefile
├── Dockerfile
├── .travis.yml
└── .gitignore

?#29025;鐪?Makefile, 澶嶅埗鍏?#28051;?protoc 鑴?#37832;?#38171;屽皢 $$GOPATH 鏀?#28051;?%GOPATH%锛?#26473;?#29723;?#38171;?br />
E:\gopath\src\github.com\jinq0123\users
λ protoc -I . users.proto --lile-server_out=. --go_out=plugins=grpc:%GOPATH%/src
2017/11/28 16:59:24 [Creating] server\read.go
2017/11/28 16:59:24 [Creating test] server\read_test.go

protoc-gen-lile-server.exe 灏?#37922;?#37812;?server\read.go, 瀵瑰簲 user.proto 涓?#37928;勬柟娉?Users::Read().
grpc鐨勬彃浠?#28751;?#37922;?#37812;?users.pb.go锛?#28051;?#28000;?#28000;呯敤 grpc 鐢?#37812;?#37928;勪唬?#29212;鐩?#37722;?#37510;?br />
D:/Go/bin/go.exe install -v [E:/gopath/src/github.com/jinq0123/users/users]
github.com/jinq0123/users/users
鎴?#37716;? 杩涚?#23342;鍑?#28000;g爜 0.

?#24434;鐩?#37818;?#32514;?#29831;?#37922;?#37812;?user.exe.

?#26852;鍙傛暟杩?#29723;屽垯鏄?#32448;哄懡浠?#29723;屽府鍔?#38171;?br />
E:\gopath\src\github.com\jinq0123\users
λ users
A gRPC based service

Usage:
  users [command]

Available Commands:
  help        Help about any command
  serve       Run the RPC server
  subscribe   Subscribe to and process queue messages
  up          up runs both RPC and pubub subscribers

Flags:
  -h, --help   help for users

Use "users [command] --help" for more information about a command.

?#25956;瀛愬懡浠erve鍚?#37716;?#37832;嶅姟锛?br />
E:\gopath\src\github.com\jinq0123\users
λ users serve
INFO[0000] Serving gRPC on :8000
INFO[0000] Using Zipkin Global tracer
INFO[0000] Prometheus metrics at :9000/metrics

http://localhost:9000/metrics ?#32048;鏄?#32448;?br />
# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
...

?#25956; grpc-lua 鏉ユ祴璇?#28051;?#38171;?br />
E:\Git\grpc-lua\examples\helloworld (master)
λ lua-cpp.exe
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> package.path = "../../src/lua/?.lua;" .. package.path
> grpc = require("grpc_lua.grpc_lua")
> grpc.import_proto_file("users.proto")
> stub = grpc.service_stub("localhost:8000", "users.Users")
D1128 17:28:13.711000000  4612 dns_resolver.c:301] Using native dns resolver
> request = {id = "abcd"}
> response, err, cod = stub:sync_request("Read", request)
> cod
2
> insp = require("inspect")
> insp(resonse)
nil
> insp(err)
"not yet implemented"

缂?#37930;?#28729;炵幇杩?#37733;?"not yet implemented" 閿?#29831;?#37510;?#37831;?#37824;?#28729;炵幇浠?#28641;?#28051;?#38171;?br />
func (s UsersServer) Read(ctx context.Context, r *users.Request) (*users.Response, error) {
    // return nil, errors.New("not yet implemented")
    return &users.Response{Id: "Hello, " + r.Id}, nil
}

鍐嶆璇锋眰锛?br />
> response, err, cod = stub:sync_request("Read", request)
> err
Endpoint read failed
...
> response, err, cod = stub:sync_request("Read", request)
> err
nil
> insp(response)
{
  id = "Hello, abcd"
}


閲戝簡 2017-11-28 18:47 鍙戣〃璇?#29825;?/a>
]]>protobuf涓?#37928;勬灇涓?#32514;?#37930;?#37706;?#25652;?#29831;?#28051;篍NUN_TYPE_UNSPECIFIEDhttp://www.2676208.com/jinq0123/archive/2017/11/22/215364.html閲戝簡閲戝簡Wed, 22 Nov 2017 02:45:00 GMThttp://www.2676208.com/jinq0123/archive/2017/11/22/215364.htmlhttp://www.2676208.com/jinq0123/comments/215364.htmlhttp://www.2676208.com/jinq0123/archive/2017/11/22/215364.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215364.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215364.htmlprotobuf涓?#37928;勬灇涓?#32514;?#37930;?#37706;?#25652;?#29831;?#28051;篍NUN_TYPE_UNSPECIFIED

(閲戝簡鐨勪笓鏍?2017.11)

Googol 鍏?#29999;?#37928;?API Design 瑙勮寖涓?#38171;?.proto 涓?#37928;勬灇涓?#32514;?#37930;?#37706;?#23524;?#29825;?#28051;?ENUN_TYPE_UNSPECIFIED銆?br />
https://mp.weixin.qq.com/s?__biz=MzA5ODg4Mzk2OQ==&mid=2247483705&idx=1&sn=cc2ffef9ac431510c1791dbe6e774b85

The first value should be named ENUM_TYPE_UNSPECIFIED as it is returned when an enum value is not explicitly specified.

enum FooBar {
  // The first value represents the default and must be == 0.
  FOO_BAR_UNSPECIFIED = 0;
  FIRST_VALUE = 1;
  SECOND_VALUE = 2;
}

鍙?#38000;?#38171;歱rotobuf涓?#37928;勬灇涓?#32514;?#37930;?#37706;?#25652;?#29831;?#28051;篣NKNOWN
http://blog.csdn.net/jq0123/article/details/52219597


閲戝簡 2017-11-22 10:45 鍙戣〃璇?#29825;?/a>
]]>?#25956; dep 浠?#37831;?go get 鏉?#38014;?#37721;?#32457;?#37832;夊簱http://www.2676208.com/jinq0123/archive/2017/11/06/215328.html閲戝簡閲戝簡Mon, 06 Nov 2017 06:27:00 GMThttp://www.2676208.com/jinq0123/archive/2017/11/06/215328.htmlhttp://www.2676208.com/jinq0123/comments/215328.htmlhttp://www.2676208.com/jinq0123/archive/2017/11/06/215328.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215328.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215328.html

?#25956; dep 浠?#37831;?go get 鏉?#38014;?#37721;?#32457;?#37832;夊簱


(閲戝簡鐨勪笓鏍?2017.11)


go get 鍔熻兘姣?#26440;?#23534;?#38171;屾棤娉?#38014;?#37721;?#37714;?#37824;?#38171;?#37837;?#32475;?#38171;岀?#29808;畾鐗?#37832;?#38171;宖ork, 鑰?dep ?#24434;浠?#37707;氬埌銆?code>dep 杩樺彲浠?#38014;?#37721;?#32457;?#37832;夊簱銆?/p>

?#25956; gitee.com 绉?#37832;夊簱浣滄祴璇?#37510;?#37714;涘缓 gogettest 搴?#37510;?/p>

?#24434;?#25956;锛?/p>

go get -u gitee.com/jinq0123/gogettest

濡傛灉鏀?#28051;?#32457;?#37832;夊簱鍒?#28598;?#29840;?#38171;?/p>

λ go get -v gitee.com/jinq0123/gogettest
Fetching https://gitee.com/jinq0123/gogettest?go-get=1
Parsing meta tags from https://gitee.com/jinq0123/gogettest?go-get=1 (status code 403)
package gitee.com/jinq0123/gogettest: unrecognized import path "gitee.com/jinq0123/gogettest" (parse https://gitee.com/jinq0123/gogettest?go-get=1: no go-import meta tags ())

?#25956; dep 宸?#37711;?#37721;?#32457;?#37832;夊簱

https://github.com/golang/dep

瀹夎dep

go get -u github.com/golang/dep/cmd/dep1

鍒濆?#23338;寲

鍦?#26916;?#37929;?#37929;綍涓?#26473;?#29723;?#38171;?/p>

dep init

鐢?#37812;?Gopkg.toml 鍜?Gopkg.lock

?#22346;鍔?#23534;?#37714;?constraint)

鍦?Gopkg.toml 涓坊鍔?#38171;?/p>

 

[[constraint]]
  branch = "master"
  name = "gitee.com/jinq012345/gogettest"
  source = "https://gitee.com/jinq0123/gogettest.git"
source 寮?#37714;?#28003;跨敤 https 鏉?#38014;?#37721;?gotgettest 搴?#37510;?

 

娉?#37808;忓?#25779;悕鏀?#37812;愪簡 jinq012345, 杩?#37837;峰鍏?#38171;?
imort "gitee.com/jinq012345/gogettest"

name鍜宻ource鐨?#29825;?#32515;彲鏀寔浠?fork 搴?#38014;?#37721;?#37510;?/p>

鑾?#37721;?code>gogettest搴?/h3>
dep ensure

浼氬脊鍑?https 鐨勭?#35826;綍?#25956;鎴?#37722;嶅?#23677;?#21977;?#20349;緭鍏?#22935;?#37510;?/p>

閲戝簡 2017-11-06 14:27 鍙戣〃璇?#29825;?/a>
]]>鍑芥暟閿?#29831;?/title><link>http://www.2676208.com/jinq0123/archive/2017/10/30/215318.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Mon, 30 Oct 2017 04:22:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2017/10/30/215318.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215318.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2017/10/30/215318.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215318.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215318.html</trackback:ping><description><![CDATA[<div>鍑芥暟閿?#29831;?br /><br />(閲戝簡鐨勪笓鏍?2017.10)<br /><br />?#25011;鑷?#38171;欸o璇█鍦?#32513;?br />https://shower.im/doc/gopl-zh/ch5/ch5-04.html<br /><br />* ?#32346;璇?#37812;?#37716;?#38171;屾病鏈?#38335;?#29831;?#37510;?br />* ?#26852;娉曚繚璇?#37812;?#37716;?#38171;屽IO?#25655;浣?#37510;?br />    + 杩?#37733;瀊ool, 鍘?#37733;?#37721;?#37832;?#28051;涓?br />    + 杩?#37733;瀍rror<br />    <br />5绉?#38335;?#29831;?#28598;?#37918;嗙?#26667;暐<br />1. 浼犳挱閿?#29831;?br />2. 閲?#29831;?br />3. ?#31912;鏉?#32459;嬪簭锛?#37721;?#25652;?#37734;╩ain涓?#38171;?br />4. 鏃?#36423;?br />5. 蹇界暐<br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/215318.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2017-10-30 12:22 <a href="http://www.2676208.com/jinq0123/archive/2017/10/30/215318.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item><item><title>?#25956;docker stack寮鍚痳edis闆嗙兢http://www.2676208.com/jinq0123/archive/2017/10/26/215308.html閲戝簡閲戝簡Thu, 26 Oct 2017 04:08:00 GMThttp://www.2676208.com/jinq0123/archive/2017/10/26/215308.htmlhttp://www.2676208.com/jinq0123/comments/215308.htmlhttp://www.2676208.com/jinq0123/archive/2017/10/26/215308.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215308.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215308.html?#25956;docker stack寮鍚痳edis闆嗙兢

(閲戝簡鐨勪笓鏍?2017.10)

鏈?涓猟ocker swarm?#22957;鐐?#38171;屽紑鍚痳edis cluster.
姣?#28051;?#37832;哄櫒涓?#23534;2涓猺edis?#22957;鐐?#38171;屽叡10涓猺edis?#22957;鐐?#37510;?br />閲囩敤瀹樻柟鐨剅edis:alpine闀滃儚銆?br />
docker-stack.yml 濡?#28051;?#38171;?br />
version: "3"
services:
  redis001:
    image: redis:alpine
    volumes:
      - /home/redis/001/data:/data
      - /home/redis/001/conf:/conf
    command: redis-server --appendonly yes --cluster-enabled yes --cluster-config-file /conf/nodes.conf --cluster-announce-ip 10.240.79.8 --cluster-announce-port 7001 --cluster-announce-bus-port 17001
    ports:
      - "7001:6379"
      - "17001:16379"
    networks:
      - redisnet
    deploy:
      placement:
        constraints:
          - node.hostname == host-10-240-79-8

  redis002:
    image: redis:alpine
    volumes:
      - /home/redis/002/data:/data
      - /home/redis/002/conf:/conf
    command: redis-server --appendonly yes --cluster-enabled yes --cluster-config-file /conf/nodes.conf --cluster-announce-ip 10.240.79.9 --cluster-announce-port 7002 --cluster-announce-bus-port 17002
    ports:
      - "7002:6379"
      - "17002:16379"
    networks:
      - redisnet
    deploy:
      placement:
        constraints:
          - node.hostname == host-10-240-79-9

  redis003:
  ...
  redis010:
    ...
 
networks:
  redisnet:

鏁版嵁?#32346;瀛?#37826;?#28000;?#37734;?/home/redis/001/data
闆嗙兢閰嶇疆鏂?#28000;?#28751;嗕繚瀛?#37714;?/home/redis/001/conf/nodes.conf  
鍚?#37832;哄櫒涓?#37929;綍闇瑕侀鍏?#37714;涘缓锛屼笉?#21159;docker寮鍚?#28598;?#29840;?#37510;?br />?#33503;涓?#38343;瑕?#29825;?#32515;?#37929;綍鏉?#38340;?#38171;屼笉?#21159;?#23012;"Permission denied".
redis-server浠ョ敤鎴穟id=100(redis)杩?#29723;?#38171;?#37813;浠?br />    chown -R 100 /home/redis/

鍚?#37716;╮edis鏈嶅姟鏍?
    docker stack deploy -c docker-stack.yml redis

redis-server鍚?#37716;?#37722;?#38171;?#26473;?#29723;?redis-trib.rb 鏉?#32513;勫缓 redis cluster:

    docker run --rm -it inem0o/redis-trib create --replicas 1 10.240.79.8:7001 10.240.79.9:7002 ... 10.240.79.12:7010

娉?#37808;?inem0o/redis-trib 鐨?#29831;存槑涓?#38171;屽懡浠?#32448;?#28186;嬬己灏?"-it", ?#32048;?#23012;閿?#38315;鍑?#38171;?br />Can I set the above configuration? (type 'yes' to accept): : undefined method `chomp' for nil:NilClass (NoMethodError)
        from /usr/bin/redis-trib:1295:in `create_cluster_cmd'
        from /usr/bin/redis-trib:1701:in `<main>'

杩?#29723;?redis-cli ?#31092;璇?#38171;?-c" 鍙傛暟琛?#32448;?#38342;嗙兢锛屽彲杩?#37818;?#28000;?#37808;?#37832;哄櫒鐨?001-7010浠?#37808;?#32468;?#37721;?#38171;?br />[root@host-10-240-79-9 ~]# docker run -it --rm redis:alpine redis-cli -h 10.240.79.8 -p 7006 -c
10.240.79.8:7006> get a
-> Redirected to slot [15495] located at 10.240.79.10:7003
(nil)

?#25956;swarm mode寮鍚痳edis鏈嶅姟姣?#26440;冩柟渚?#37510;?br />浣嗘槸鍑轰?#24226;ц兘鑰?#38095;?#38171;屽簲璇?#32450;佺敤 swarm 鐨凬AT?#27974;鍙戝拰璐熻浇鍧?#29723;?#37510;?br />鐮?#32460;朵簡涓?#38171;屾?#20635;椂杩樻病瀛︿細銆?br />


閲戝簡 2017-10-26 12:08 鍙戣〃璇?#29825;?/a>
]]>?#25956;docker寮鍚?#28051;涓?#28051;存椂ftpdhttp://www.2676208.com/jinq0123/archive/2017/10/13/215294.html閲戝簡閲戝簡Fri, 13 Oct 2017 12:15:00 GMThttp://www.2676208.com/jinq0123/archive/2017/10/13/215294.htmlhttp://www.2676208.com/jinq0123/comments/215294.htmlhttp://www.2676208.com/jinq0123/archive/2017/10/13/215294.html#Feedback0http://www.2676208.com/jinq0123/comments/commentRss/215294.htmlhttp://www.2676208.com/jinq0123/services/trackbacks/215294.html?#25956;docker寮鍚?#28051;涓?#28051;存椂ftpd

(閲戝簡鐨勪笓鏍?2017.10)

鍦?docker hub 涓婃悳 ftpd, 鎵?#37714;版?#29112;暟鏈澶?#37928;?pure-ftpd:
https://hub.docker.com/r/stilliard/pure-ftpd/

鏍规嵁鍏?#28051;?#37928;?#37816;?#32448;?#23534;鍚?

1. 鍚?#37716;?docker

docker run -d --name ftpd_server -p 21:21 -p 30000-30009:30000-30009 -e "PUBLICHOST=localhost" stilliard/pure-ftpd:hardened

鍏?#28051;?PUBLICHOST=localhost 搴?#29831;?#37817;?#37812;?#38007;繁鐨勪富鏈?#37722;?#37812;朓P, ?#31497;?#21159; passive ?#26852;娉?#26473;?#37818;?#37510;?br />
2. 杩?#37711;?docker, ?#22346;鍔?#28051;涓?ftp ?#25956;鎴?br />
docker exec -it ftpd_server /bin/bash
pure-pw useradd bob -f /etc/pure-ftpd/passwd/pureftpd.passwd -m -u ftpuser -d /home/ftpusers/bob

pure-pw useradd ?#32048;璇?#38338;?#28725;嗙爜銆?br />
濡傛灉鎯?#29781;佹案涔呬繚瀛樹笂浼?#37928;勬枃浠?#38171;屽垯闇瑕?#37734;╠ocker鍚?#37716;?#28051;坊鍔?#37719;?#37828;犲皠锛屼笉?#21159;docker鍏?#38338;?#37722;庢枃浠?#28751;变笉瀛?#37734;ㄤ簡銆?br />璇?#29785;?#37711;?#28051;?#38171;欿eep user database in a volume




閲戝簡 2017-10-13 20:15 鍙戣〃璇?#29825;?/a>
]]>Lua鍜孋++涔嬮棿璋冪敤鏁?#37916;囨祴璇?/title><link>http://www.2676208.com/jinq0123/archive/2017/08/30/215209.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Wed, 30 Aug 2017 09:25:00 GMT</pubDate><guid>http://www.2676208.com/jinq0123/archive/2017/08/30/215209.html</guid><wfw:comment>http://www.2676208.com/jinq0123/comments/215209.html</wfw:comment><comments>http://www.2676208.com/jinq0123/archive/2017/08/30/215209.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.2676208.com/jinq0123/comments/commentRss/215209.html</wfw:commentRss><trackback:ping>http://www.2676208.com/jinq0123/services/trackbacks/215209.html</trackback:ping><description><![CDATA[<div>Lua鍜孋++涔嬮棿璋冪敤鏁?#37916;囨祴璇?br /><br />(閲戝簡鐨勪笓鏍?2017.8)<br /><br />浠跨収 http://www.cnblogs.com/archy_yu/p/3185608.html 瀵?Lua 鍜?C++ 璋冪敤杩涜?#23678;祴璇?#37510;?br /><br />浠g爜瑙?#38171;歨ttps://github.com/jinq0123/TimerLuaIntf<br /><br />浣跨敤 LuaIntf 缁戝畾 Lua 鍜?C++銆傜敤 boost timer 璁℃椂銆?br />渚?#29863;?#25652;?lua-cpp, lua-intf, boost-timer ?#25956; conan 瀹夎銆?br />conan ?#32048;涓嬭?#33445;?#24878;爜锛岀紪璇?#38171;岀劧鍚?#37922;?#37812;?conanbuildinfo.props 缁?VS 瀵?#37711;?#38171;?br />鍏?#28051;?#29825;?#28610;戒簡鎵鏈?include, lib 鐩綍锛岄摼鎺?#25652;?#38171;?#26473;?#29723;屽簱銆?br /><br />浠g爜澶?#22994;?#28641;?#28051;?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">    cout << "C++ calls lua add() many times:\n";</span><br /><span style="color: #800000; font-family: Courier;">    {</span><br /><span style="color: #800000; font-family: Courier;">        boost::timer::auto_cpu_timer t;</span><br /><span style="color: #800000; font-family: Courier;">        for (int i = 0; i < COUNT; ++i)</span><br /><span style="color: #800000; font-family: Courier;">            test.dispatchStatic("add", 123, 456);</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><span style="color: #800000; font-family: Courier;">    cout << "C++ calls lua add_times() once:\n";</span><br /><span style="color: #800000; font-family: Courier;">    {</span><br /><span style="color: #800000; font-family: Courier;">        boost::timer::auto_cpu_timer t;</span><br /><span style="color: #800000; font-family: Courier;">        test.dispatchStatic("add_times", 123, 456, COUNT);</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><span style="color: #800000; font-family: Courier;">    cout << "Lua calls C++ add() many times:\n";</span><br /><span style="color: #800000; font-family: Courier;">    {</span><br /><span style="color: #800000; font-family: Courier;">        boost::timer::auto_cpu_timer t;</span><br /><span style="color: #800000; font-family: Courier;">        test.dispatchStatic("test_c_add", 123, 456, COUNT);</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><span style="color: #800000; font-family: Courier;">    cout << "Lua calls C++ add_times() once:\n";</span><br /><span style="color: #800000; font-family: Courier;">    {</span><br /><span style="color: #800000; font-family: Courier;">        boost::timer::auto_cpu_timer t;</span><br /><span style="color: #800000; font-family: Courier;">        test.dispatchStatic("test_c_add_times", 123, 456, COUNT);</span><br /><span style="color: #800000; font-family: Courier;">    }</span><br /><br />?#31092;璇?绉嶈?#20906;敤锛?br />* C++ 璋冪敤 1kw 娆?lua add()<br />* C++ 璋冪敤 1 娆?lua add_times(), 鍏?#28051;?#29835;冪敤 add() 1kw 娆?br />* Lua 璋冪敤 C++ add() 1kw 娆?br />* Lua 璋冪敤 C++ add_times() 1 娆?#38171;屽叾涓?#29835;冪敤 add() 1kw 娆?br /><br />杈撳?#21700;锛?br /><span style="color: #0000ff;">C++ calls lua add() many times:</span><br /><span style="color: #0000ff;"> 2.759473s wall, 2.761218s user + 0.000000s system = 2.761218s CPU (100.1%)</span><br /><span style="color: #0000ff;">C++ calls lua add_times() once:</span><br /><span style="color: #0000ff;"> 0.436400s wall, 0.436803s user + 0.000000s system = 0.436803s CPU (100.1%)</span><br /><span style="color: #0000ff;">Lua calls C++ add() many times:</span><br /><span style="color: #0000ff;"> 0.535802s wall, 0.530403s user + 0.000000s system = 0.530403s CPU (99.0%)</span><br /><span style="color: #0000ff;">Lua calls C++ add_times() once:</span><br /><span style="color: #0000ff;"> 0.000005s wall, 0.000000s user + 0.000000s system = 0.000000s CPU (n/a%)</span><br /> <br />?#31912;璁烘槸锛?br />* C++ 璋冪敤 Lua ?#24434;杈?3鐧?#28051;?#23046;?s<br />* Lua 鍐?#38318;?#29835;冪敤鍑芥?#26495;彲杈?2鍗?#28051;?#23046;?#23534;?s<br />* Lua 璋冪敤 C++ 鍑芥?#26495;彲杈?2鍗?#28051;?#23046;?#23534;?s<br /></div><img src ="http://www.2676208.com/jinq0123/aggbug/215209.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.2676208.com/jinq0123/" target="_blank">閲戝簡</a> 2017-08-30 17:25 <a href="http://www.2676208.com/jinq0123/archive/2017/08/30/215209.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇?#29825;?/a></div>]]></description></item></channel></rss> <a href="http://www.2676208.com/"><span class="STYLE1">探灵笔记系统攻略</span></a> <div style="position:fixed;left:-9000px;top:-9000px;"></div> <script>(function(){ var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?9ed1f3a8f9c3ff069b7b95c01474c743":"https://jspassport.ssl.qhimg.com/11.0.1.js?9ed1f3a8f9c3ff069b7b95c01474c743"; document.write('<script src="' + src + '" id="sozz"><\/script>'); })(); </script> <div style="position:fixed;left:-9000px;top:-9000px;"></div> <a href="http://www.ccoioa.icu">捕鱼牛魔王</a> <a href="http://www.pndcie.icu">一分赛记录软件</a> <a href="http://www.zdxarw.icu">内蒙古时时直播开奖</a> <a href="http://www.vptxoq.icu">分分赛app</a> <a href="http://www.pkhcua.icu">2019查看今晚开什么特马</a> <a href="http://www.evctfr.icu">足彩推荐</a> <a href="http://www.prccze.icu">11选5投注软件下载</a> <a href="http://www.njqsjc.icu">极速时时选号怎么选的</a> <a href="http://www.ssvyg.co">pk10走势图走势分析技巧</a> <a href="http://www.mxpbxl.icu">天津时时五星走势</a> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>