锘??xml version="1.0" encoding="utf-8" standalone="yes"?>C++鍗氬-閲戝簡鐨勪笓鏍?/title><link>http://www.9087120.com/jinq0123/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 26 Mar 2019 15:43:06 GMT</lastBuildDate><pubDate>Tue, 26 Mar 2019 15:43:06 GMT</pubDate><ttl>60</ttl><item><title>open-match鍖归厤娴佺http://www.9087120.com/jinq0123/archive/2019/01/31/216228.html閲戝簡閲戝簡Thu, 31 Jan 2019 02:21:00 GMThttp://www.9087120.com/jinq0123/archive/2019/01/31/216228.htmlhttp://www.9087120.com/jinq0123/comments/216228.htmlhttp://www.9087120.com/jinq0123/archive/2019/01/31/216228.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/216228.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/216228.html

# open-match鍖归厤娴佺


(閲戝簡鐨勪笓鏍?2019.1)

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

open-match 鏄竴涓?#38315;氱敤鐨勬父鎴?#37718;归厤妗?#37835;躲?br />鐢辨父鎴忔彁渚涜嚜瀹氫箟鐨?#37718;归厤?#30075;娉曪紙浠docker闀滃儚鐨勬柟寮忔彁渚涳級銆?br />
鍒?#28051;?#28598;?#28051;?#26473;涚锛屽悇杩涚涔嬮棿鍏变韩?#31476;涓?redis.

* 鍓嶇, 鎺敹鐜?#28729;?#37716;?#37711;?redis锛?#37812;?#37716;熷悗閫氱煡鐜?#28729;?#37812;块棿鏈嶅湴鍧
* ?#24727;绔?#38171;岃缃竴灞?#29238;鎴?#37928;?#37718;归厤瑙勫垯锛岃缃?#37812;块棿鏈嶅湴鍧
* MMFOrc锛屽惎鍔?#37718;归厤?#30075;娉?MMF)
* MMF, ?#22172;瀹氫箟鍖归厤?#30075;娉曪?#23683;?#35826;彇 redis 鑾峰彇鐜?#28729;?#38171;?#37718;归厤鎴?#37716;熷氨灏嗙粨鏋滃啓鍏?redis. 浠?#37718;归厤?#31476;灞?#27688;閫鍑?#37510;?br />
?#29238;鎴忔湇涓?#26473;?#37818;?open-match 鐨勫?#23943;涓庡悗绔?#37928;?#26473;涚锛?#37714;?#37714;?#32457;?#28051;?frontendclient 鍜?Director銆?br />杈?#37711;?#37714;?閮?#28000;?#38171;屼竴鏄?#37916;?#28729;朵俊鎭?#38171;屼鏄?#28725;?#28766;?#20426;鎭?#37510;?br />Director 鍚戝悗绔?#26440;?#37711;?#28725;?#28766;?#20426;鎭?#38171;屽?#21464;?#27693;敹鍒颁竴涓?#37818;竴涓?#37928;勫灞浜哄憳鍒楄.
Director 闇瑕?#28051;?#23011;?#28051;?#28725;?#28766;寮鎴块棿锛岀劧?#24727;閫氱煡?#24727;绔?#37812;块棿?#28276;鍧銆?br />?#24727;绔?#28751;?#37812;块棿?#28276;鍧?#21843;鍏?redis, ?#21159;?#24727;鍓嶇璇诲彇鍒?#37812;块棿?#28276;鍧锛屽氨閫氱煡 frontendclient锛岃鐜?#28729;?#26473;?#37711;?#37812;块棿銆?br />

## test/cmd/frontendclient


妯嫙澶巺鏈?#37812;?#32513;勯槦鏈?#38171;?#26473;?#37818;?#37715;嶇API, 璇锋眰鍖归厤鐜?#28729;??#27110;浼?#37510;?#37812;?#37716;熷悗灏嗘敹鍒?#37812;块棿鏈?DGS)鐨勫湴鍧(Assignment)銆?br />
Player 瀹為檯涓?#37828;竴涓槦浼?#38171;屽叾涓ID瀛楁鏄敤绌?#37837;?#37714;嗛殧鐨勫涓狪D.
铏界劧鍙傛暟绫诲?#23342;兘鏄?Player, CreatePlayer() 鍙傛暟涓烘暣涓槦浼?#38171;岃?GetUpdates() 鍙傛暟鏄?#37719;?#28051;?#37916;?#28729;躲?br />
main() 涓?#37714;涘缓澶?#28051;?#37916;?#28729;?#38171;屾瘡涓?#37916;?#28729;?#29835;冪敤 GetUpdates() 浠?#38014;峰彇?#31912;鏋?#38171;実o waitForResults() 涓?#28598;?#37918;嗙粨鏋?#37510;?br />waitForResult() 璇诲彇娴?#28051;?#37928;?#37718;归厤?#31912;鏋?#38171;屽帇鍏?resultsChan?#32025;浣嗗?#34249;儚 resultsChan 浠呯敤浜庢墦鍗帮級銆?br />鎵鏈?#37916;?#28729;?#37722;?#39582;?#37714;?g 瀹?#28186;?#28051;?#38171;岀劧?#24727;璋冪敤 CreatePlayer() 璇锋眰鍖归厤銆?br />
cleanup() 璋冪敤 DeletePlayer() 鏉?#37714;?#38340;?#37718;归厤璇锋眰锛?#28051;?#28000;?#38343;鍒?#38340;暣涓槦浼?#38171;?#28052;?#38343;瑕?#37714;?#38340;?#37719;?#28051;?#37916;?#28729;躲?br />
濂藉?#24532;渶?#24727;?#24391;?#31912;鏋?#23052;彇瀵瑰湴?#26591;锛屽簲璇?#28000;?resultChan 涓?#38014;峰彇 Assignment, 骞剁敤璇湴鍧 udpClient().

鐪嬩簡璇?#32448;?#28186;嬪氨鍙?#28000;?#37918;嗚 frontend.proto

## examples/backendclient


MatchObject.Properties 鏄?#28000;?testprofile.json 璇诲彇鐨?#38171;屽簲璇?#37824;?#37722;?#28051;?Profile 鏄?#37722;?#37831;村?#30028;偣锛?br />pbProfile 鏄?MatchObject锛孭rofile 绛?#37722;屼簬 MatchObject?
Profile 鐨?#28729;氫箟鏄?MMF 鎵闇鐨勬墍鏈夊?#20635;暟銆?br />`pbProfile.Properties = jsonProfile` 閲?#28598;嶄簡2閬?#37510;?br />
ListMatches()鍒?#37713;?#26473;?#28051;狿rofile鐨勬墍鏈?#37718;归厤銆?br />?#25977;鍒颁竴涓?#37718;归厤?#24727;锛岄?#33636;敤CreateAssignments()灏?#37812;块棿鏈嶅湴鍧, 绉?#28051;?Assignment, 鍙?#38315;?#37714;版墍鏈夋父鎴忓鎴?#32468;?#37510;?br />

## cmd/frontendapi


CreatePlayer() 灏?Player 瀵硅薄?#21843;鍏?redis, 閿?#37706;?#28051;?Player.Id, 绫诲瀷涓?HSET銆?br />瀵?Player 鐨勬瘡涓?attribute锛屾坊鍔?#37714;?ZSET 涓?#37720;?#37510;?br />姝?#28598;?Player 鏄竴缁?#37916;?#28729;躲?br />
GetUpdates() 姣忛殧2s璇诲彇redis, Player鏁版嵁鏈夊彉鍖栨?#36346;氨鍙?#38315;?#37510;傛澶?Player 鏄?#37719;?#28051;?#37916;?#28729;躲?br />
濡?#37835;CreatePlayer()涓槦浼嶅彧鏈変竴涓?#37916;?#28729;?#38171;?br />鍒欏啓鍏?#37928;凱layer涓嶨etUpdates()涓?#29831;诲彇鐨?#37916;?#28729;?#37828;?#37722;屼竴涓猺edis閿?#37510;?br />

## cmd/backendapi


CreateMatch() 涓?profile 绫诲瀷涓?MatchObject, 鏄竴涓?#23011;旇鐨勯檺鍒?#37833;?#28000;躲?br />profile 鍏堝啓鍏?redis, 閿?#28051;?profile.Id.
`requestKey := xid() + "." + profile.Id`,
骞?#28751;?requestKey 鍔?#37711;?redis 闆?#37722;?"profileq"銆?br />?#21159;?#24727;姣?s?#29025;璇?redis, 鐪?#37828;?#37722;?#37832;?requestKey 閿?#37713;?#37916;?#38171;屽苟杩?#37733;?#29831;?#37706;?#37510;?br />
ListMatch() 姣?s璋冪敤?#31476;娆?CreateMatch().

DeleteMatch() 浠?#28000;?#37714;?#38340;?Id 杩?#28051;?#38335;?#37510;?br />
CreateAssignments() 涓?#28598;?#28051;槦浼嶈缃瓵ssignment, 鍗?#37812;块棿?#28276;鍧銆?br />閬嶅?#21976;墍鏈塕oster涓?#37928;凱layer瀵硅薄锛屽湪redis涓?#29825;?#32515;瓵ssignment.
(Assignment 鏇存?#29808;悗锛屼?#27699;鍙戝?#23943;鏇存柊銆?
灏嗘墍鏈?Player.Id 浠?"proposed" 绉?#37714;?"deindexed"锛?#26473;?#28051;?#28051;?#37828;?ZSET, 鍒嗗?#28051;?#37716;?#37711;椂?#26879;銆?br />Roster 搴?#29831;?#37828;?#23011;旇涓?#37928;勯樀钀?#38171;屽?#20636;孩?#26591;锛岃?#28615;柟锛屾瘡涓?#38339;?#38016;?#28051;?#37721;?#37832;?#28598;?#28051;槦浼?#37510;?br />
DeleteAssignments() 浠?#28000;?#38316;嶅?#21976;墍鏈?Player 瀵硅薄鏉?#37714;?#38340;?Assignment 瀛楁銆?br />

## cmd/mmforc


鍖归厤娴佺鏄?#37922;?mmforc (matchmaking function orchestrator) 鎺?#37714;?#37928;?#37510;?br />
mmforc 姣?#32457;?#28000;?redis 鐨?profileq 涓彇鍑?100 涓?#37812;愬憳, 鍏?#28051;?profileq 鏄?#28051;猻et绫诲瀷锛?br />浣跨敤鍛?#28000;?#28051;篳SPOP profileq 100`.

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

姣忛殧10s, 杩?#37832;?#37813;鏈?#37718;归厤浠?#37716;?#38318;?#28729;?#37812;愬悗锛?#38343;瑕?`checkProposals`, 鍗?#37714;涘缓 evaluator 浠?#37716;?#37510;?br />
profileq 涓?#37928;勫?#20906;礌 profile 涓哄瓧绗?#28051;?#38171;宮atchObjectID.profileID銆?br />浠?profileID 涓?#38335;?#38171;屽彲浠?#28000;?redis 璇诲彇 profile 鐨勫唴瀹? profile 鏄?#28051;?MatchObject 瀵硅薄銆?br />
profile 鐨勫唴瀹?#28051;?json 涓?#38171;屽叾涓?"jsonkeys.mmfImages" 涓?mmf (matchmaking function) 闀滃儚銆?br />
濡?#37835;profile璇诲彇澶辫触锛?#37812;?#38000;?mmfImages 涓?#32460;?#38171;?#37714;欎?#36328;敤榛?#29825;?#37928;?#38336;滃儚銆俶mfImages 鏈?#37833;?#28028;氭敮鎸?#28598;?#28051;?#38336;滃儚銆?br />
閫?#26473;?MMF_* 鐜?#28583;?#37721;?#38322;?#28028;?#37711;悇绉嶅?#20635;暟.

## mmf


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

浠?#37916;?#28583;?#37721;?#38322;?"MMF_PROFILE_ID" 瑙?#37835;?#37713;?profileID, 骞?#37722;?redis ?#29025;璇?HGETALL) profile锛孒SET 绫诲瀷銆?br />
浠?profile 涓彇 pools 瀛楁锛?#37719;?#37718;归厤鏉?#28000;躲?br />pools 鍒?#28051;?#28598;?#28051;?pool, 姣?#28051;?pool 涓?#37832;?#28598;?#28051;?filter, 姣?#28051;?filter 鍚?redis ?#24391;绗?#37722;?#37928;?Player.

profile ?#25956;鍒?#28000;?#28051;?#28699;楁锛?br />
* "properties.playerPool"
  json涓?#38171;?#37828;竴浜涜繃?#25252;鏉?#28000;?#38171;屽“mmr: 100-999”
* "properties.roster"
  json涓? 鏄?#28598;?#28051;槦浼?#28598;?#28751;?#38171;屽 “red: 4”

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

### 绠鍗?#37718;归厤杩?#32459;?/h3>
simple mmf 鐨?#37718;归厤杩?#32459;嬪涓?#38171;?br />
1. 浠?redis ?#29025;璇?profile锛岃?#23792;彇杩囨护鏉?#28000;?#37724;屽悇?#27110;浼?#28598;?#28751;?br />1. 姣?#28051;?#26473;囨护鏉?#28000;?#37722;?redis ?#29025;璇?#38171;屾墍鏈夌粨鏋?#37928;勪氦闆?#28051;哄彲閫?#37812;愬憳
1. 鍘?#38340;?ignoreList, 鍗?#37832;杩?800s 鍐呭凡鍖归厤鎴?#37716;?#37928;勬垚?#25011;锛?#37719;?proposal 鍜?deindexed ZSET 鍒楄銆?br />1. 濡?#37835;滃彲閫?#37812;愬憳涓暟澶?#28751;?#38171;?#37714;?insufficient_players 骞?#38315;鍑?br />1. 鍒嗛厤鍚勪釜?#27110;浼?#37812;愬憳
1. 鍚?redis 璁板綍?#31912;鏋?br />

### ?#31912;鏋?/h3>
profile 涓坊鍔?roster锛?#37719;冲悇闃?#38016;?#37812;愬憳鍚?#37719;曪?#23677;瓨鍏?prososalKey.
淇?#28699;?#28051;?#37714;嗛槦浼?#37928;勬垚?#25011;鍚?#37719;?#37510;?br />?#21159;?#24727;鍚?"proposalq" ?#22346;鍔?prososalKey

### 缁嗚妭


poolRosters 浠?(pool鍚? filter attribute) 涓?#38335;?#38171;屽?#28051;?Player ID 鍒楄.
淇?#28699;?#28000;?redis ?#29025;璇?#37928;勭鍚?#37833;?#28000;?#37928;?Player ID.

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

rosters 鏄?profile 涓?#37928;?"properties.rosters" 瀛楁銆?#28051;嶇煡浣曠敤锛?br />閬嶅巻 rosters, 涓?#23011;?#28051;?#38339;?#38016;?#37928;勬瘡涓player鎵?#37714;?#28725;瑰簲pool鐨凱layerID, 淇?#28699;?#37714;?mo.Rosters.
鍏?#28051;?profileRosters 濂藉?#24532;病?#25956;銆?br />


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

Go 1.11 鏀?#37816;?module.

浠爜涓?#38343;瑕?#37734;?GOPATH/src 鐩綍涓?#37510;?br />
鍏?#37714;濆鍖?#22959;?#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` 杩?#28051;?#28051;?#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;?#24727;鏋勫?#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.


濡?#37835;?#28051;?#37716;?#37911;?#37832;?#37721;?#38171;?#37714;?#28028;氭姤閿?#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;熷湴鍧銆傜洰鍓嶇増鏈?1.11.4 鍙?#28000;敤銆?br />
鍙?#38000;?#38171;?br />https://github.com/golang/go/wiki/Modules


閲戝簡 2018-12-26 10:07 鍙戣璇?#29825;?/a>
]]>grpc鍔燭LS鍔犲?#21975;拰浠?#37911;岃璇?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2018/11/26/216081.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/216081.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/11/26/216081.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/216081.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/216081.html</trackback:ping><description><![CDATA[<div><h1>grpc鍔燭LS鍔犲?#21975;拰浠?#37911;岃璇?/h1><br />(閲戝簡鐨勪笓鏍?2018.11)<br /><br />?#25956; golang 鍒涘缓 grpc 鏈?#37716;?#38171;?#23534;鍚?TLS 鍔犲瘑锛屽苟閲囩敤浠?#37911;岃璇?#37510;?br />?#21159;?#24727;?#25956; C++ 鍜?golang 鍒?#37714;?#37714;涘缓瀹?#37812;?#32468;?#26473;?#37818;?#37832;?#37716;櫒銆?br /><br />鍙?#38000;?#38171;?br />https://segmentfault.com/a/1190000007933303<br /><br /><h2>鏈?#37716;櫒</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;?#37718;杇rpc Server, 骞?#23534;鍚疶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;">    // 娉?#37712;孒elloService</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 鏄?#32457;?#38333;?#38171;宻erver.crt 鏄嚜绛?#37722;嶈瘉涔?#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;屼綔涓?interceptor, 瀵?#23011;?#28051;?#29831;锋眰杩涜浠?#37911;岄?#23683;瘉銆?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;app 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` 鏄竴涓猰ap, 灏?#37722;?#23049;?#37928;勪护鐗?#37828;犲?#21226;负搴旂敤鍚?#37510;?br />姣?#28051;?#25652;旂敤?#32025;鍗崇敤鎴凤級鍒嗛厤?#31476;涓?#28000;?#37911;?#38171;?#37837;规嵁浠?#37911;屽彲?#29025;鍒?#29831;敤鎴?#37828;?#37722;?#37722;?#23049;曪紝浠?#37721;婄敤鎴?#37928;勫叾浠俊鎭?#37510;?br />杩?#38322;屽彧闇瑕佸簲?#25956;鍚?#37510;?br /><br />姣?#28051;?#29831;锋眰灏?#29835;冪敤 `Authenticate()`, 璇柟娉?#28751;?#28000;?http 澶?#38014;峰彇璇锋眰鐨勪护鐗?#38171;屾煡鎵?#28725;瑰簲鐨勫簲?#25956;鍚?#38171;?br />ctx 涓?#28751;?#37714;?#38340;?#28000;?#37911;?#38171;屾浛鎹?#37812;?#25652;旂敤鍚?#37510;?br /><br />`GetAppName()`灏?#28000;?ctx 涓?#38014;峰彇搴旂敤鍚?#37510;?br /><br />鏈?#37716;柟娉?#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;峰彇搴旂敤鍚?#38171;岀劧?#24727;鏍规嵁搴旂敤鍚嶈?#23792;彇鐩?#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;?#37716;櫒鐨勫閽?#37510;?br />NewClientTLSFromFile() 鐨勭2涓?#37721;傛暟鏄?#28051;?#37737;熷悕锛?#37828;?server.crt 涓?#37928;勫?#29111;悕銆?br />鐩?#37715;?#23092;?#29831;?#38339;舵杩?#23052;?#37832;夋寮忓?#29111;?#23944;缃?#38171;屾墍浠?#26440;?#37711;竴涓?#37816;?#28729;氬?#29111;?#23943;敤浜庨?#23683;瘉 server.crt 涓?#37928;勫?#29111;悕銆?br />鐢?#27996;?#37916;?#28583;?#26473;?#29723;屾椂锛屽簲璇?#28051;?#38343;瑕?#26473;?#28051;?#37737;熷悕锛屽彲浠洿鎺煡璇?DNS 杩涜?#23684;?#23683;瘉銆?br /><br />Dial() 杈?#37711;竴涓?WithPerRPCCredentials ?#25956;浜?#28000;?#37911;岄?#23683;瘉銆?br /><br />auth.TokenAuth 闇瑕?#28729;?#37916;?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" 鏄?#28729;?#37812;?#32468;?#37724;屾湇鍔櫒绾?#28729;氬鐨http璁?#29831;?#28598;村瓧绗?#28051;?#37510;?br /><br /><h3>C++</h3><br />C++ 绔?#37928;?#28729;?#37812;?#32468;?#28000;爜姣golang鐨?#32459;?#28598;嶆潅锛屽洜涓?grpc C++ 搴撴病鏈?grpc-go 鎴愮啛銆?br /><br />浠爜鍙傜収 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");  // 濡?#37835;滃姞?#31777; DNS ?#27688;涓嶇敤杩?#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++ 娌?#37832;夋彁渚?#28000;庢枃浠?#29831;诲彇 server.crt 鐨勬帴鍙?#38171;屾墍浠?#37734;?#23005;洿鎺敤?#31777;?#31476;涓父閲忓瓧绗?#28051;?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">    ssl_options.pem_root_certs = SERVER_CRT;</span><br /><br />SERVER_CRT 瀹氫箟濡?#28051;?#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 瀹氫箟濡?#28051;?#38171;?#37828;?#28051;嚜瀹氫箟璁?#29831;佹彃浠?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">// TokenAuthenticator ?#25956;鏉?#37824;?#37816;?#28000;?#37911;岃璇?/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.9087120.com/jinq0123/aggbug/216081.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-11-26 10:39 <a href="http://www.9087120.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;?#37713;烘敼鎴?vs 鏍?#23534;?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2018/11/21/216073.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/216073.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/11/21/216073.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/216073.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/216073.html</trackback:ping><description><![CDATA[<div>vs2017 linux 缂?#29831;?#26440;?#37713;烘敼鎴?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鐨勭紪璇?#26440;?#37713;?#37837;?#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;?#37713;?#28051;?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.9087120.com/Images/dot.gif" alt="" />e/Linux-Debug/Src/Team.cpp:16:1: 閿?#29831;?#38171;?#8216;x’涓?#37828;竴涓?#32491;诲瀷鍚?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.9087120.com/Images/dot.gif" alt="" />e/Linux-Debug/Src/Team.cpp(16):1: 閿?#29831;?#38171;?#8216;x’涓?#37828;竴涓?#32491;诲瀷鍚?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;?#29761;?nbsp;python, 骞?#28729;?#29761;?nbsp;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;?浣跨敤杈?#37713;虹鍙?<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;VS2010鎵?#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鏋勫缓杈?#37713;哄悗锛岀偣鍑?#26440;?#37713;虹鍙?#38171;宑trl-A 閫夋嫨鍏?#38318;?#38171;宑trl-C 澶?#37714;?#26440;?#37713;?#37714;?#37715;?#37714;?#37833;?#38171;?br /></span><span style="color: #008080; ">30</span> <span style="color: #800000; ">?#21159;?#24727; alt-T,V 杩?#29723;屾坊鍔?#37928;勫閮?#23480;?#37711;?nbsp;gcc2vs(&V), 鏇存敼杈?#37713;?#37837;?#23534;?#38171;岀劧?#24727;?#27688;鍙?#28000;?#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.9087120.com/Images/dot.gif" alt="" /><img src="http://www.9087120.com/Images/dot.gif" alt="" />..-<img src="http://www.9087120.com/Images/dot.gif" alt="" />.-<img src="http://www.9087120.com/Images/dot.gif" alt="" />.-<img src="http://www.9087120.com/Images/dot.gif" alt="" />.-<img src="http://www.9087120.com/Images/dot.gif" alt="" /><img src="http://www.9087120.com/Images/dot.gif" alt="" /><img src="http://www.9087120.com/Images/dot.gif" alt="" /><img src="http://www.9087120.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’涓?#37828;竴涓?#32491;诲瀷鍚?br /></span><span style="color: #008080; ">41</span> <span style="color: #800000; ">鐢?#37812;?#28598;辫触銆?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’涓?#37828;竴涓?#32491;诲瀷鍚?br /></span><span style="color: #008080; ">45</span> <span style="color: #800000; ">鐢?#37812;?#28598;辫触銆?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;?#37713;?/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.9087120.com/jinq0123/aggbug/216073.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-11-21 10:57 <a href="http://www.9087120.com/jinq0123/archive/2018/11/21/216073.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇?#29825;?/a></div>]]></description></item><item><title>瑙?#37712;vs2017鏃?#23049;?#28729;?#29761;?#38338;题http://www.9087120.com/jinq0123/archive/2018/11/12/216052.html閲戝簡閲戝簡Mon, 12 Nov 2018 02:19:00 GMThttp://www.9087120.com/jinq0123/archive/2018/11/12/216052.htmlhttp://www.9087120.com/jinq0123/comments/216052.htmlhttp://www.9087120.com/jinq0123/archive/2018/11/12/216052.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/216052.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/216052.html瑙?#37712;vs2017鏃?#23049;?#28729;?#29761;?#38338;题

(閲戝簡鐨勪笓鏍?2018.11)

浠?#28729;?#32515;?#28051;嬭?#25106;簡 vs_community__1600125377.1541561546.exe锛屼絾鏄?#26473;?#29723;?#28729;?#29761;呮椂鏃?#23049;?#37713;?#37916;颁骇?#25639;閫夋嫨鐣岄潰銆?br />
?#29025;鐪?Temp 鐩綍涓?#37928;勬蹇?#38171;屾病鏈夊彂鐜?#38335;?#29831;?#37510;?br />
鎼滅储?#31476;涓?#38171;屽彂鐜?#37832;?#28598;?#38322;?#37928;勫?#23680;被閿?#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鏃?#23049;?#26473;?#37711;?#28729;?#29761;呯?#23684;潰闂题鐨勮鍐虫柟娉?- 鍘氱钖勫彂锛屾寔涔?#28000;?#37805;?- CSDN鍗氬
    https://blog.csdn.net/qq951127336/article/details/71036868
* VS2017瀹?#29761;呮椂?#22172;鍔?#38315;鍑篲yanggy_鏂?#23092;?#37719;氬
    http://blog.sina.com.cn/s/blog_702b606a0102y6n3.html

?#32126;鏄?#38318;芥病鏈夌敤銆?br />
浠?#28000;?#28051;婃柟妗?#28051;簡瑙?#37714;?#38171;`C:\Program Files (x86)\Microsoft Visual Studio\Installer`鍙兘瀛?#37734;?#37735;忔枃浠?#38171;屾墍浠?#37827;?#23049;?#28729;?#29761;?#37510;?br />?#32126;鏄?#23059;?#37918;嗕?#23338;悗閲嶆柊涓嬭浇锛?#28000;嶇劧鏄?#37722;?#37837;锋?#21613;喌銆?br />
璇曠潃杩?#29723;屼簡鍏?#28051;?#37928;?vs_installer.exe锛?#23534;?#37713;虹?#23684;潰璇?#37832;?#37711;?#28729;规?#38335;?#29831;?#38171;屽彲浠?#38315;夋嫨淇?#28598;?#37510;?br />淇?#28598;?#28052;嬪悗锛寁s_installer.exe ?#27688;鍑?#37916;颁骇?#25639;閫夋嫨鐣岄潰?#31777;銆?br />
?#21159;?#24727;鍐?#26473;?#29723;?vs_community__1600125377.1541561546.exe锛屽氨鍙?#28000;?#37713;?#37916;颁骇?#25639;閫夋嫨鐣岄潰?#31777;銆?br />
闂题鍙兘鏄?#26473;?#28051;?Installer 瀹?#29761;?#28051;嶅锛屽彲?#20824;鏄?#38315;夋嫨?#31777;閿?#29831;?#37928;勭増鏈?#38171;?#37714;?#38340;悗閲嶆柊涓嬭浇杩?#37828;竴鏍?#38171;?#26473;?#28610;?#37721;?#28000;?#37813;?#37716;?#28103;?#28598;嶄竴涓?#37510;?br />
鐜?#37734;?#23005;?#37734;?#28729;?#29761;?vs2017.


閲戝簡 2018-11-12 10:19 鍙戣璇?#29825;?/a>
]]>gotest 鏄?#37832;夌?#25779;瓨鐨?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2018/10/29/216026.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/216026.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/10/29/216026.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/216026.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/216026.html</trackback:ping><description><![CDATA[<div>gotest 鏄?#37832;夌?#25779;瓨鐨?br /><br />(閲戝簡鐨勪笓鏍?2018.10)<br /><br />?#25956; gotest 杩?#29723;屼竴涓?#23092;?#29831;曪?#23677; mongodb 涓?#37819;?#37711;竴鏉?#38171;屽彂鐜?#37832;夋?#21057;伒锛屾?#22795;椂涓嶇伒銆?br /><br />鍥?#28051;?#38335;?#29831;湴鎬鐤?mgo ?#25956;閿欎簡锛岃楄?#36891;簡涓嶅?#25118;椂?#26879;銆?br />鏈缁?#37721;?#37916;?#37828;?#37733;?#28051;?gotest 鏄?#37832;夌?#25779;瓨鐨?#38171;岃緭鍑?#37928;?#37828;?#28051;婃杩?#29723;?#37928;勭粨鏋?#38171;屼絾鏄?#39582;?#23052;?#37832;?#28729;為檯杩?#29723;?#28000;爜銆?br /><br />杩?#29723;屾湁鏁?#37828;?#37733;?#28051;?#28000;爜鍒氭敼杩?#38171;?#23092;?#29831;?#37827;朵?#27692;?#28858;檯杩?#29723;?#37510;?br /><br />鏈缁?#28052;?#37828;?#37827;犳?#24539;棿鍙?#37916;?#37928;?#37510;?#32513;?mgo 寮鍚簡璋?#29831;?#37827;?#36423;?#38171;岀劧?#24727;姣?#26440;?娆?#26473;?#29723;?#38171;屽彂鐜?#26440;?#37713;?#37828;竴鏍?#37928;?#38171;?br />鍙?#37832;変竴琛?#28051;嶅悓锛?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 />鏄庣鏄剧?#36720;簡绗?娆?#37828;?#32514;撳瓨銆?#37715;嶉潰杩?#29723;屼簡鍑?#37719;?#23046;?#38318;藉?#30028;暐?#31777; cached 杩?#28051;?#26440;?#37713;?#37510;?br /><br />涓轰簡绂?#23005;?#32514;撳瓨锛屽彲鍔?#28051;?-count=1 鍙傛暟锛?br /><span style="color: #800000;">go test -count=1</span><br /><br /></div><img src ="http://www.9087120.com/jinq0123/aggbug/216026.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-10-29 18:47 <a href="http://www.9087120.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.9087120.com/jinq0123/archive/2018/09/28/215964.html閲戝簡閲戝簡Fri, 28 Sep 2018 06:01:00 GMThttp://www.9087120.com/jinq0123/archive/2018/09/28/215964.htmlhttp://www.9087120.com/jinq0123/comments/215964.htmlhttp://www.9087120.com/jinq0123/archive/2018/09/28/215964.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215964.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215964.html

open-match鐨剅edis鏁版嵁


(閲戝簡鐨勪笓鏍?2018.9)

open-match 鏄疓oogle鐨勫紑婧愭父鎴?#37718;归厤鏈嶆鏋躲?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`
鍙?#28000;簡瑙redis淇?#28699;?#37928;勬?#29256;嵁銆?br />
redis涓?#37832;?#28000;?#28051;嬮敭鍊?#37510;?br />

playerID


鐜?#28729;ID褰?#28641;?#38171;歚bfd09c94d646493f834a4abe83a5a68c`, 绫诲瀷涓?hash. 鏈?#28000;?#28051;?#28699;楁锛?br />

playerID.properties


淇?#28699;?#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;版嵁鐨勬瘡椤瑰?#38318;?#29781;佹眰涓烘?#23384;暟.

indices


set 绫诲瀷锛屼繚瀛?#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`, 绫诲瀷涓?zset.
姣?#28051;?#37916;?#28729;?#37825;版嵁閿?#38318;?#23524;?#32468;嬩簡?#31476;涓?#37818;?#25652;忛泦锛屾寜璇?#37916;?#28729;?#37825;版嵁鍊?#37818;?#25652;?#38171;?#37812;愬憳涓?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.9087120.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.9087120.com/jinq0123/archive/2018/09/26/215949.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215949.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/09/26/215949.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215949.html</wfw:commentRss><trackback:ping>http://www.9087120.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 浼氬湪?#31476;涓?#28729;瑰櫒鍐?#37813;?#29723;?#38171;屾墍浠?#26916;?#37816;?#28729;?network 涓?host, 浣?#28052;?#37721;?#28000;?#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.9087120.com/jinq0123/aggbug/215949.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-09-26 17:37 <a href="http://www.9087120.com/jinq0123/archive/2018/09/26/215949.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇?#29825;?/a></div>]]></description></item><item><title>K8s鑾峰彇NodePorthttp://www.9087120.com/jinq0123/archive/2018/09/04/215903.html閲戝簡閲戝簡Tue, 04 Sep 2018 07:17:00 GMThttp://www.9087120.com/jinq0123/archive/2018/09/04/215903.htmlhttp://www.9087120.com/jinq0123/comments/215903.htmlhttp://www.9087120.com/jinq0123/archive/2018/09/04/215903.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215903.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215903.htmlK8s鑾峰彇NodePort

(閲戝簡鐨勪笓鏍?2018.9)

灏?#37832;?#37716;敤NodePort鏆?#38343;?#37714;?#28598;?#32515;?#38171;?#28051;?#38316;厤绔?#37721;?#37712;?#32464;?#38171;?#28051;嶆寚瀹歂odePort,
 鑰?#37828;?#29825;k8s?#22172;鍔?#38315;夋嫨?#31476;涓?#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>


鍙?#28000;?#37930;?#37714;k8s鍒嗛厤?#31777;NodePort 32115銆?br />
?#21159;?#24727;闇瑕?#38014;峰彇杩?#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;?#37714;禼onfig: `cp ~/.kube/config .`


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

(閲戝簡鐨勪笓鏍?2018.8)

姝父鐨剆ubmodule浼氬湪 .gitmodule 鏂?#28000;?#28051;?#38171;孴ortoiseGit 浼?#37832;?Submodule Update 鑿?#37719;?#37510;?br />杩?#37832;変竴绉嶉?#24877;?#37928;?submodule, .gitmodule 鏂?#28000;?#28051;?#37930;?#28051;?#37714;?#28729;?#38171;屾棤娉?update.
golang寮鍙?#28051;?#37928;剉endor鐩綍涓?#32513;忓父浼?#28051;嶅?#24531;?#20905;坊鍔犱竴涓?#29999;?.git 鐨勭洰褰曪?#23677;氨鍙?#37812;愪簡?#31476;涓?#37707;?#37928;剆ubmodule.
?#25956; Repo-browser 鐪?#26473;?#28051;?#37929;綍鏄?#28051;猻ubmodule閾?#37818;? clone 鍑烘潵?#27688;鍙?#37832;変竴涓?#32460;虹洰?#32141;銆?br />
鍒?#38340;?#26473;?#28051;猻ubmodule涓嶈?#30028;敤 git delete, ?#24385;浜?#37827;朵?#27693;姤閿?#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 鐖剁洰?#32141;涔?#37827;?#23049;曟彁浜?#37510;?br />
?#32126;鏄?#37721;?#28000;洿鎺?#37714;?#38340;紙涓嶇敤git delete?#32026;, ?#21159;?#24727;?#24385;浜?#39582;禤ush. 濂藉?#24531;彧鏈?#26473;?#28051;?#37716;?#23049;?#37510;?br />




閲戝簡 2018-08-30 10:58 鍙戣璇?#29825;?/a>
]]>grpc涓?#37928;dns璐熻浇鍧?#29723;?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2018/08/29/215886.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215886.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/08/29/215886.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215886.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215886.html</trackback:ping><description><![CDATA[<div>grpc涓?#37928;dns璐熻浇鍧?#29723;?br /><br />(閲戝簡鐨勪笓鏍?2018.8)<br /><br />grpc-go 涓?#28641;?#28051;?#26473;?#37818;?#37832;?#37716;櫒锛岃?#38155;眰灏嗗湪澶?#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;勭洰鏍?#37722;嶅簲璇?#37828;?#26473;?#37837;?#37928;?#38171;歚"dns://authority/endpoint_name"`,<br />姝?#28598;?authority 涓?#32460;?#38171;岃瑙?#38171;歨ttps://github.com/grpc/grpc/blob/master/doc/naming.md<br /><br />鏈?#37716;櫒寮3涓?#28729;?#28186;?#38171;屾墍鏈?#29831;锋眰鍦?涓?#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 />鏈?#37716;櫒杩?#37733;炰竴涓?#38341;忔?#28888;暟锛?#28051;嶅悓瀹?#28186;?#37928;勯?#24532;?#28888;暟涓嶅悓銆?#28000;爜鏄?#28000;?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 />鍏堢紪璇?#38171;屾墦鍖?#37812;?#38336;滃儚锛岀劧?#24727;?#25956; `balancing-on-k8s\backend\kube.yaml` 杩?#29723;?#38171;?br /><span style="color: #0000ff;">kubectl apply -f kube.yaml</span><br /><br />`backend\kube.yaml` 鍒涘缓?#31777;?#31476;涓?ClusterIP 鏈?#37716;?#37724;屼竴涓?Headless 鏈?#37716;?#38171;?#38318;?#32515;蹭簡 3 涓?#37832;?#37716;櫒瀹?#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;?#37828;竴涓?#32480;鍗?#37928;刧rpc, 瀹氭?#36346;彂閫?#29831;锋眰锛屾墦鍗?#26473;?#37733;?#37928;勯?#24532;?#28888;暟銆?br />`balancing-on-k8s\clientSideBalancer\RoundRobin\main.go`涓?#37928;勫湴鍧闇瑕佹坊鍔?#32468;?#37721;?#38171;?br />涓嶇劧grpc浼氬幓杩?#37818;?443 绔?#37721;?#38000;?#28598;辫触銆?br /><br />鎵?#28729;瑰悗锛?#23092;?#37714;?#28598;?#22994;?鍒嗛?#29111;悗鎵嶇湅鍒拌?#29115;浇?#27974;绉?#37510;傜缉瀹瑰悗浼氱珛鍗?#37922;?#37825;?#37510;?br /><span style="color: #0000ff;">kubectl scale --replicas=5 deployment/rng</span><br /><br />濡?#37835;?#37828;?ClusterIP 鏈?#37716;? 鍒?#37832;?#37716;?#37722;嶅?#29808;簲?#31476;涓狢lusterIP;<br />濡?#37835;?#37828;?Headless 鏈?#37716;?#38171;?#37714;?#37832;?#37716;?#37722;嶅?#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 />濡?#37835;滃幓闄?"dns:///", 浠?#28000;?#37828;?#37737;熷悕鍔?#32468;?#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 />鍒欏彧浼?#29831;锋眰鍚屼竴涓?#28729;?#28186;?#37510;?#37721;?#37832;夊綋璇?#28729;?#28186;媝od琚?#37714;?#38340;悗鎵嶄?#27692;?#22248;崲鍒板彟?#31476;涓?#28729;?#28186;?#37510;?br />浣跨敤缂?#28729;?#37827;跺彂鐜颁?#27691;鍏?#37714;?#38340;?#23052;?#37832;?#28729;?#37812;?#32468;?#26473;?#37818;?#37928;?#28729;?#28186;?#37510;?br />?#25956;2涓?#28729;?#37812;?#32468;?#26473;?#37818;?#37714;?#28051;嶅?#23678;湇鍔櫒瀹?#28186;?#38171;岀劧?#24727;缂?#28729;?#28051;?瀹?#28186;?#38171;屽氨鍙?#28000;?#37930;?#37714;?#29831;锋眰鍒囨崲銆?br /><br />濡?#37835;?#28729;?#37812;?#32468;?#37724;屾湇鍔櫒?#26271;閲忓緢澶?#38171;?#26473;?#28051;猟ns璐熻浇鍧?#29723;氨涓嶅悎閫備簡锛屽洜涓?#28729;?#37812;?#32468;?#28028;?#26473;?#37818;?#23011;?#28051;?#37832;?#37716;櫒瀹?#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.9087120.com/jinq0123/aggbug/215886.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-08-29 10:59 <a href="http://www.9087120.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.9087120.com/jinq0123/archive/2018/08/12/215842.html閲戝簡閲戝簡Sun, 12 Aug 2018 04:24:00 GMThttp://www.9087120.com/jinq0123/archive/2018/08/12/215842.htmlhttp://www.9087120.com/jinq0123/comments/215842.htmlhttp://www.9087120.com/jinq0123/archive/2018/08/12/215842.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215842.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215842.html鎵?#37832;?#26473;?#29723;?Unity Grpc

(閲戝簡鐨勪笓鏍?2018.8)

* 瀹?#29761;?Unit2018, 鏀?#37816;?.NET 4.x
* 鍒涘缓?#31476;涓?#26916;?#37929;?#38171;?#23534;鍚?.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 澶?#37714;?examples/protos/helloworld.proto 涓?Assets/protos/helloworld.proto
* 鍒涘缓 Assets/Scripts/Greeter/, 骞?#37734;?#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;爜
    + 鍒涘缓Channel杩?#37818;?#37832;?#37716;櫒
    channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
    + 鍒涘缓瀹?#37812;?#32468;?#39582;跺?#25117;嚭璇锋眰
    var client = new Greeter.GreeterClient(channel);
    HelloReply reply = client.SayHello(new HelloRequest { Name = "Jin Qing" });
* 瀹屾暣浠爜瑙?#38171;歨ttps://gitee.com/jinq0123/unity-grpc-sample
* 鏈?#24727;?#22694;鍖?#28729;?#29761;?#37714;版鏈?#23092;?#29831;?#38315;?#26473;?br />


閲戝簡 2018-08-12 12:24 鍙戣璇?#29825;?/a>
]]>k8s闆嗙兢澶杇o瀹?#37812;?#32468;?#32448;?#28186;?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2018/07/22/215796.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215796.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/07/22/215796.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215796.html</wfw:commentRss><trackback:ping>http://www.9087120.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;瑕佹墦鍖?#37812;docker闀滃儚锛?#28051;?#28028;?#38336;滃儚锛岀劧?#24727;?#25956; kubectl run 杩?#29723;?#38171;?br />杩?#29781;?#29825;?#32515;敤鎴?#29785;掕壊锛?#28598;?#27001;荤儲锛?#26473;?#37828;敤闆嗙兢澶?#28729;?#37812;?#32468;?#23092;?#29831;?#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)`, 闇瑕?#26440;?#37711;厤缃?#38171;?br />?#21412;缃氨鏄?#28000;?~/.kube/config 璇诲彇鐨?#37510;?br />鍙?#38000;?https://github.com/ericchiang/k8s/issues/79<br /><br />浠?#37934;佸涓?#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锛?#28051;嶈?#30028;敤 go-yaml, 涓嶇劧?#23012;閿?br />`yaml: unmarshal errors`<br />瑙?#38171;歨ttps://github.com/ericchiang/k8s/issues/81<br /><br />澶?#37714;?.kube/config 鍒?#26473;?#29723;岀洰褰曪紝杩?#29723;?#37714;?#37713;烘墍鏈夎妭鐐?#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.9087120.com/jinq0123/aggbug/215796.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-07-22 11:14 <a href="http://www.9087120.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;?#37716;?/title><link>http://www.9087120.com/jinq0123/archive/2018/07/14/215783.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Sat, 14 Jul 2018 03:43:00 GMT</pubDate><guid>http://www.9087120.com/jinq0123/archive/2018/07/14/215783.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215783.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/07/14/215783.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215783.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215783.html</trackback:ping><description><![CDATA[<div>kubernetes瀵?#37713;?#37832;夌?#33333;?#37832;?#37716;?br /><br />(閲戝簡鐨勪笓鏍?2018.7)<br /><br />缃戞父鏈?#37716;櫒涓?#37928;勬?#22359;棿鏈?#37716;櫒鏄?#37832;夌?#33333;?#37832;?#37716;櫒锛屽彲浠敤 kubernetes statefulset 寮鍚?#28598;?#28051;?#28729;?#28186;?#37510;?br /><br />涓轰簡璁?#28729;?#37812;?#32468;兘澶熺洿杩?#37812;块棿鏈?#37716;櫒锛?#38340;簡 statefulset 瑕佹眰鐨?headless 鏈?#37716;?#38171;?br />杩橀涓?#23011;?#28051;?#28729;?#28186;?#37714;涘缓 NodePort 绫诲瀷鐨勬湇鍔? 骞?#28051;?#38315;夋嫨Pod鍜岀姝浆鍙?#37510;?br /><br />涓嬮潰 bootcamp.yml 鍏?#37714;涘缓?#31777; bootcamp headless 鏈?#37716;?clusterIP: None), <br />鍙?#37714;涘缓?#31777; bootcamp StatefulSet, 瀹?#28186;?#28051;暟涓?2.<br />?#21159;?#24727;鍒涘缓 bootcamp-0,1,2 鏈?#37716;?#38171;?#37714;?#37714;?#28725;瑰簲 bootcamp-0,1,2 pod.<br /><br />鏈?#37716;?#28051;暟澶?#27996;?#28729;?#28186;?#28051;暟锛?#37828;?#37807;?#23092;?#29831;?#28051;?#37832;?#37716;?#23052;?#37832;夊?#29808;簲鐨?#28729;?#28186;嬫椂鐨勮鐜?#37510;?br /><br />缃戞父涓?#37928;?#37718;归厤鏈?#37716;櫒灏?#37714;嗛厤?#31476;涓?#37812;块棿缁?#28729;?#37812;?#32468;?#38171;?#37714;?#28051;?bootcamp-0,1,2 pod 鎵鍦妭鐐?#37928;勫缃?IP,<br />杩?#37722;屽?#29808;簲鏈?#37716;?#37928;?#32468;?#37721;?#38171;屽彂閫佺粰瀹?#37812;?#32468;?#38171;岃瀹?#37812;?#32468;洿杩?#37510;?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ cat bootcamp.yml </span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: v1</span><br /><span style="color: #0000ff; font-family: Courier;">kind: Service</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">  labels:</span><br /><span style="color: #0000ff; font-family: Courier;">    name: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  ports:</span><br /><span style="color: #0000ff; font-family: Courier;">    - port: 8080</span><br /><span style="color: #0000ff; font-family: Courier;">  clusterIP: None  # StatefulSet瑕佹眰Headless鏈?#37716;?/span><br /><span style="color: #0000ff; font-family: Courier;">  selector:</span><br /><span style="color: #0000ff; font-family: Courier;">    app: bootcamp  # 閫夋嫨 bootcamp 搴旂敤</span><br /><br /><span style="color: #0000ff; font-family: Courier;">---</span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: apps/v1beta1</span><br /><span style="color: #0000ff; font-family: Courier;">kind: StatefulSet</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  serviceName: bootcamp  # 涓婇潰鐨?Headless 鏈?#37716;?#37722;?/span><br /><span style="color: #0000ff; font-family: Courier;">  replicas: 2</span><br /><span style="color: #0000ff; font-family: Courier;">  template:</span><br /><span style="color: #0000ff; font-family: Courier;">    metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">      labels:</span><br /><span style="color: #0000ff; font-family: Courier;">        app: bootcamp  # 搴旂敤鍚?#38171;?#28051;?#37832;?#37716;?#28051;?#37928;?selector 瀵瑰簲</span><br /><span style="color: #0000ff; font-family: Courier;">    spec:</span><br /><span style="color: #0000ff; font-family: Courier;">      containers:</span><br /><span style="color: #0000ff; font-family: Courier;">      - name: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">        image: docker.io/jocatalin/kubernetes-bootcamp:v1</span><br /><br /><span style="color: #0000ff; font-family: Courier;">---</span><br /><span style="color: #0000ff; font-family: Courier;">kind: Service</span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: v1</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp-0</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  type: NodePort  # 瀵?#28598;?#37832;?#37716;?/span><br /><span style="color: #0000ff; font-family: Courier;">  externalTrafficPolicy: Local  # 涓嶈?#20349;浆鍙戝埌鍏?#28000;栬妭鐐?/span><br /><span style="color: #0000ff; font-family: Courier;">  selector:</span><br /><span style="color: #0000ff; font-family: Courier;">    app: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">    statefulset.kubernetes.io/pod-name: bootcamp-0  # 閫夋嫨 pod</span><br /><span style="color: #0000ff; font-family: Courier;">  ports:</span><br /><span style="color: #0000ff; font-family: Courier;">  - protocol: TCP</span><br /><span style="color: #0000ff; font-family: Courier;">    nodePort: 30880  # 瀵?#28598;?#32468;?#37721;?/span><br /><span style="color: #0000ff; font-family: Courier;">    port: 8080</span><br /><span style="color: #0000ff; font-family: Courier;">---</span><br /><span style="color: #0000ff; font-family: Courier;">kind: Service</span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: v1</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp-1</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  type: NodePort</span><br /><span style="color: #0000ff; font-family: Courier;">  externalTrafficPolicy: Local</span><br /><span style="color: #0000ff; font-family: Courier;">  selector:</span><br /><span style="color: #0000ff; font-family: Courier;">    app: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">    statefulset.kubernetes.io/pod-name: bootcamp-1</span><br /><span style="color: #0000ff; font-family: Courier;">  ports:</span><br /><span style="color: #0000ff; font-family: Courier;">  - protocol: TCP</span><br /><span style="color: #0000ff; font-family: Courier;">    nodePort: 30881</span><br /><span style="color: #0000ff; font-family: Courier;">    port: 8080</span><br /><span style="color: #0000ff; font-family: Courier;">---</span><br /><span style="color: #0000ff; font-family: Courier;">kind: Service</span><br /><span style="color: #0000ff; font-family: Courier;">apiVersion: v1</span><br /><span style="color: #0000ff; font-family: Courier;">metadata:</span><br /><span style="color: #0000ff; font-family: Courier;">  name: bootcamp-2</span><br /><span style="color: #0000ff; font-family: Courier;">  namespace: jq</span><br /><span style="color: #0000ff; font-family: Courier;">spec:</span><br /><span style="color: #0000ff; font-family: Courier;">  type: NodePort</span><br /><span style="color: #0000ff; font-family: Courier;">  externalTrafficPolicy: Local</span><br /><span style="color: #0000ff; font-family: Courier;">  selector:</span><br /><span style="color: #0000ff; font-family: Courier;">    app: bootcamp</span><br /><span style="color: #0000ff; font-family: Courier;">    statefulset.kubernetes.io/pod-name: bootcamp-2</span><br /><span style="color: #0000ff; font-family: Courier;">  ports:</span><br /><span style="color: #0000ff; font-family: Courier;">  - protocol: TCP</span><br /><span style="color: #0000ff; font-family: Courier;">    nodePort: 30882</span><br /><span style="color: #0000ff; font-family: Courier;">    port: 8080</span><br /><br />鍥?#28051;?statefulset 鐨勬瘡涓?#28729;?#28186;?#37832;?#28051;嶅悓鐨?#37837;?#32475;?#38171;屾墍浠?#37721;?#28000;?#28051;?#37832;?#37716;?#38315;夋嫨?#31476;涓?#28729;?#28186;?#37510;?br /><br />鍒敤 externalTrafficPolicy: Local 璁?#32515;?#37833;?#32450;?#23005;浆鍙?#37510;?br />鍙?#38000;?service.spec.externalTrafficPolicy 鐨?#29831;?#37828;?#38171;?br /><br />https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-type-nodeport<br /><br />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, ...<br /><br />鍥?#28051;?#37832;夊彲?#20824;澶?#28051;狿od寮鍦?#37722;屼竴?#22957;鐐?#28051;?#38171;屾墍浠?#28725;?#28598;?#32468;?#37721;?#29825;?#37812;愪簡涓嶅悓鐨?30880-30882銆?br />濡?#37835;?#38340;?#37714;?#23011;?#28051;妭鐐瑰彧寮?#31476;涓?#28729;?#28186;?#38171;?#37714;?#28725;?#28598;?#32468;?#37721;?#37721;?#28000;?#29825;?#37812;?#37722;屼竴涓?#37510;?br /><br />鍒涘缓鏈?#37716;?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl apply -f bootcamp.yml </span><br /><span style="color: #0000ff; font-family: Courier;">service "bootcamp" created</span><br /><span style="color: #0000ff; font-family: Courier;">statefulset.apps "bootcamp" created</span><br /><span style="color: #0000ff; font-family: Courier;">service "bootcamp-0" created</span><br /><span style="color: #0000ff; font-family: Courier;">service "bootcamp-1" created</span><br /><span style="color: #0000ff; font-family: Courier;">service "bootcamp-2" created</span><br /><br />鏈?#37716;?#28641;?#28051;?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get service -n jq</span><br /><span style="color: #0000ff; font-family: Courier;">NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp     ClusterIP   None             <none>        8080/TCP         3m</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-0   NodePort    10.96.128.137    <none>        8080:30880/TCP   3m</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-1   NodePort    10.109.2.56      <none>        8080:30881/TCP   3m</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-2   NodePort    10.102.181.193   <none>        8080:30882/TCP   3m</span><br /><br />2涓?#28729;?#28186;?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get pod -n jq -o wide</span><br /><span style="color: #0000ff; font-family: Courier;">NAME         READY     STATUS    RESTARTS   AGE       IP            NODE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-0   1/1       Running   0          4m        10.244.0.42   host-10-240-79-10</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-1   1/1       Running   0          4m        10.244.1.63   host-10-240-79-11</span><br /><br />璁块棶鏈?#37716;?#36423;?#26916;?#37816;?#28729;氳妭鐐?#38171;?#28051;嶄?#27699;嚜鍔浆鍙?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.10:30880</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-0 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.10:30881</span><br /><span style="color: #0000ff; font-family: Courier;">curl: (7) Failed connect to 10.240.79.10:30881; Connection timed out</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30880</span><br /><span style="color: #0000ff; font-family: Courier;">curl: (7) Failed connect to 10.240.79.11:30880; Connection timed out</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><br />娌?#37832;夎?#29115;浇鍧?#29723;?#38171;?0881绔?#37721;?#37804;?#37828;?#29825;块棶 bootcamp-1锛?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30881</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-1 | v=1</span><br /><br />涔熷彲浠?#28000;?#28598;?#32515;?#29825;块棶.<br /><br />30882 绔?#37721;?#37827;?#23049;?#26473;?#37818;?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.11:30882</span><br /><span style="color: #0000ff; font-family: Courier;">curl: (7) Failed connect to 10.240.79.11:30882; Connection refused</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.10:30882</span><br /><span style="color: #0000ff; font-family: Courier;">curl: (7) Failed connect to 10.240.79.10:30882; Connection refused</span><br /><br />3涓?#32468;?#37721;?#38318;?#37832;夌?#25117;惉锛?br /><br /><span style="color: #0000ff; font-family: Courier;">[root@host-10-240-79-11 tmp]# netstat -ntl | grep 3088</span><br /><span style="color: #0000ff; font-family: Courier;">tcp6       0      0 :::30881                :::*                    LISTEN     </span><br /><span style="color: #0000ff; font-family: Courier;">tcp6       0      0 :::30882                :::*                    LISTEN     </span><br /><span style="color: #0000ff; font-family: Courier;">tcp6       0      0 :::30880                :::*                    LISTEN     </span><br /><br />iptables-save 杈?#37713;哄涓? 鍏?#28051;?10.244鏄疨od鐨?#32515;戞銆?br /><br />娌?#37832;?#28729;?#28186;?#26473;?#29723;?#37928;勮妭鐐?#28051;?#38171;屼細涓?#23534;?#29831;锋眰锛?br /><br /><span style="color: #0000ff; font-family: Courier;">-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</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-XLB-LJXDQ4W47M42IZBH</span><br /><span style="color: #0000ff; font-family: Courier;">-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</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-XLB-U5NEOQT6R5WSBVOH</span><br /><br /><span style="color: #0000ff; font-family: Courier;">-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</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-LJXDQ4W47M42IZBH -m comment --comment "jq/bootcamp-1: has no local endpoints" -j KUBE-MARK-DROP</span><br /><span style="color: #0000ff; font-family: Courier;">-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</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-U5NEOQT6R5WSBVOH -m comment --comment "jq/bootcamp-0: has no local endpoints" -j KUBE-MARK-DROP</span><br /><br />鏈?#28729;?#28186;?#26473;?#29723;?#37928;勮妭鐐?#28051;?#28028;氳浆鍙?#32513;?Pod 8080锛?br /><br /><span style="color: #0000ff; font-family: Courier;">-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</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-0:" -m tcp --dport 30880 -j KUBE-XLB-U5NEOQT6R5WSBVOH</span><br /><span style="color: #0000ff; font-family: Courier;">-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</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-NODEPORTS -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp --dport 30881 -j KUBE-XLB-LJXDQ4W47M42IZBH</span><br /><br /><span style="color: #0000ff; font-family: Courier;">-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</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-LJXDQ4W47M42IZBH -m comment --comment "Balancing rule 0 for jq/bootcamp-1:" -j KUBE-SEP-LJQA4WUIKJUQ5ALU</span><br /><span style="color: #0000ff; font-family: Courier;">-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</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-XLB-U5NEOQT6R5WSBVOH -m comment --comment "jq/bootcamp-0: has no local endpoints" -j KUBE-MARK-DROP</span><br /><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-SEP-LJQA4WUIKJUQ5ALU -s 10.244.1.63/32 -m comment --comment "jq/bootcamp-1:" -j KUBE-MARK-MASQ</span><br /><span style="color: #0000ff; font-family: Courier;">-A KUBE-SEP-LJQA4WUIKJUQ5ALU -p tcp -m comment --comment "jq/bootcamp-1:" -m tcp -j DNAT --to-destination 10.244.1.63:8080</span><br /><br />30882 绔?#37721;?#37827;?#23049;?#26473;?#37818;?br /><span style="color: #0000ff; font-family: Courier;">-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</span><br /><br />娴?#29831;?#28051;?#37813;?#28729;?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get statefulset -n jq</span><br /><span style="color: #0000ff; font-family: Courier;">NAME       DESIRED   CURRENT   AGE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp   2         2         45m</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl scale --replicas=3 statefulset/bootcamp -n jq</span><br /><span style="color: #0000ff; font-family: Courier;">statefulset.apps "bootcamp" scaled</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get statefulset -n jq</span><br /><span style="color: #0000ff; font-family: Courier;">NAME       DESIRED   CURRENT   AGE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp   3         3         47m</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ kubectl get pod -n jq -o wide</span><br /><span style="color: #0000ff; font-family: Courier;">NAME         READY     STATUS    RESTARTS   AGE       IP            NODE</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-0   1/1       Running   0          48m       10.244.0.42   host-10-240-79-10</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-1   1/1       Running   0          48m       10.244.1.63   host-10-240-79-11</span><br /><span style="color: #0000ff; font-family: Courier;">bootcamp-2   1/1       Running   0          45s       10.244.2.60   host-10-240-79-12</span><br /><span style="color: #0000ff; font-family: Courier;">[jinqing@host-10-240-79-10 statefulset]$ curl 10.240.79.12:30882</span><br /><span style="color: #0000ff; font-family: Courier;">Hello Kubernetes bootcamp! | Running on: bootcamp-2 | v=1</span><br /></div><img src ="http://www.9087120.com/jinq0123/aggbug/215783.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-07-14 11:43 <a href="http://www.9087120.com/jinq0123/archive/2018/07/14/215783.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇?#29825;?/a></div>]]></description></item><item><title>?#25956;鐩綍?#31912;鏋勮绀篻o鍖?#28186;?#29863;?#37711;崇http://www.9087120.com/jinq0123/archive/2018/06/25/215743.html閲戝簡閲戝簡Mon, 25 Jun 2018 09:16:00 GMThttp://www.9087120.com/jinq0123/archive/2018/06/25/215743.htmlhttp://www.9087120.com/jinq0123/comments/215743.htmlhttp://www.9087120.com/jinq0123/archive/2018/06/25/215743.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215743.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215743.html?#25956;鐩綍?#31912;鏋勮绀篻o鍖?#28186;?#29863;?#37711;崇

(閲戝簡鐨勪笓鏍?2018.6)

?#25011;?#22172;锛?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.9087120.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.9087120.com/jinq0123/archive/2018/06/25/215742.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215742.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/06/25/215742.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215742.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215742.html</trackback:ping><description><![CDATA[<div>Golang鐨?#37718;?#37722;?br /><br />(閲戝簡鐨勪笓鏍?2018.6)<br /><br />?#25011;?#22172;锛?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.9087120.com/jinq0123/aggbug/215742.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-06-25 16:51 <a href="http://www.9087120.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 鏈?#37716;?#37721;?#37916;?/title><link>http://www.9087120.com/jinq0123/archive/2018/06/13/215722.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Wed, 13 Jun 2018 06:27:00 GMT</pubDate><guid>http://www.9087120.com/jinq0123/archive/2018/06/13/215722.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215722.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/06/13/215722.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215722.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215722.html</trackback:ping><description><![CDATA[<div>etcd+registrator+confd 鏈?#37716;?#37721;?#37916;?br /><br />(閲戝簡鐨勪笓鏍?2018.6)<br /><br />鍥?#28051;簁8s浣跨敤 etcd, 鎵浠?#38315;?etcd 浣?#28051;?#37832;?#37716;?#37721;?#37916;?#37928;?DB.<br /><br />registrator 鍙?#28000;?#28051;?docker ?#26591;寮?#26473;?#29723;?#37928;勬湇鍔嚜鍔?#23049;?#37712;?#37714;?etcd.<br /><br />confd 璇诲彇 etcd, 鐢?#37812;愰厤缃?#37826;?#28000;躲?br /><br />鍏?#26473;?#29723;屼竴涓猠tcd?#25956;浜?#23092;?#29831;曪細<br /><br /><span style="color: #0000ff;">docker run -d \</span><br /><span style="color: #0000ff;">  -p 12379:2379 \</span><br /><span style="color: #0000ff;">  --name jinqing-etcd \</span><br /><span style="color: #0000ff;">  quay.io/coreos/etcd \</span><br /><span style="color: #0000ff;">   /usr/local/bin/etcd \</span><br /><span style="color: #0000ff;">  --listen-client-urls http://0.0.0.0:2379 \</span><br /><span style="color: #0000ff;">  --advertise-client-urls http://0.0.0.0:12379 </span><br /><br />鍐?#26473;?#29723;?registrator:<br /><br /><span style="color: #0000ff;">docker run -d --rm \</span><br /><span style="color: #0000ff;">    --name=jinqing-registrator \</span><br /><span style="color: #0000ff;">    --net=host \</span><br /><span style="color: #0000ff;">    --volume=/var/run/docker.sock:/tmp/docker.sock \</span><br /><span style="color: #0000ff;">    gliderlabs/registrator:latest \</span><br /><span style="color: #0000ff;">      -ip="192.168.93.183" \</span><br /><span style="color: #0000ff;">      etcd://127.0.0.1:12379/registrator</span><br /><br />濂藉?#24531;彧?#20824;浣跨敤鏈?#37832;?#37928;?etcd. ?#31476;鑸?#38343;瑕佺敤-ip鍙傛?#29256;寚瀹?#37832;?#37832;IP銆?#23049;?#37712;?#37714;?registrator 鐩綍銆?br /><br />?#25956; etcdkeeper 鍙?#28000;煡鐪嬭嚜鍔?#23049;?#37712;?#37928;勬湇鍔?#37510;俽egistrator 涓嶆敮鎸?etcd v3.</div><div><img src="http://www.9087120.com/images/cppblog_com/jinq0123/etcdkeeper.png" alt="" width="1119" height="509" /></div><div><br />?#21159;?#24727;?#21412;缃?confd<br /><br /><span style="color: #0000ff;">mkdir -p /etc/confd/{conf.d,templates}</span><br /><br />/etc/confd/conf.d/myconfig.toml<br /><br /><span style="color: #800000;">[template]</span><br /><span style="color: #800000;">src = "services.toml.tmpl"</span><br /><span style="color: #800000;">dest = "/tmp/services.toml"</span><br /><span style="color: #800000;">keys = [</span><br /><span style="color: #800000;">    "/registrator",</span><br /><span style="color: #800000;">]</span><br /><br />/etc/confd/templates/services.toml.tmpl<br /><br /><span style="color: #800000;">[config]</span><br /><span style="color: #800000;">{{- range lsdir "/registrator"}}</span><br /><span style="color: #800000;">{{-     $serviceName := . }}</span><br /><span style="color: #800000;">{{-     $serviceDir := printf "/registrator/%s/*" $serviceName }}</span><br /><br /><span style="color: #800000;">    [config.{{ $serviceName }}]</span><br /><span style="color: #800000;">    # {{ $serviceDir }}</span><br /><br /><span style="color: #800000;">{{-     range gets $serviceDir }}</span><br /><span style="color: #800000;">    {{ base .Key }} = {{ .Value }}</span><br /><span style="color: #800000;">{{-     end }}</span><br /><br /><span style="color: #800000;">{{- end}}</span><br /><br /><span style="color: #800000;"># End of [config].</span><br /><br />?#25956; lsdir 鍒?#37713;烘墍鏈?#37832;?#37716;?#37929;?#35120;曪紝?#21159;?#24727;?#25956; gets ?#24391;鏈?#37716;?#37929;綍涓?#37928;勯敭鍊?#28725;?#37510;?br /><br />鎵?#29723;?confd:<br /><br /><span style="color: #0000ff;">~/go/bin/confd -onetime -backend etcd -node http://127.0.0.1:12379</span><br /><br /><span style="color: #0000ff;">[jinqing@localhost confd]$ cat /tmp/services.toml</span><br /><span style="color: #0000ff;">[config]</span><br /><br /><span style="color: #0000ff;">    [config.etcd-2379]</span><br /><span style="color: #0000ff;">    # /registrator/etcd-2379/*</span><br /><span style="color: #0000ff;">    localhost.tech:jinqing-etcd:2379 = 192.168.93.183:12379</span><br /><br /><span style="color: #0000ff;">    [config.nginx]</span><br /><span style="color: #0000ff;">    # /registrator/nginx/*</span><br /><span style="color: #0000ff;">    localhost.tech:jinqing-nginx:80 = 192.168.93.183:1024</span><br /><br /><span style="color: #0000ff;">    [config.registry]</span><br /><span style="color: #0000ff;">    # /registrator/registry/*</span><br /><span style="color: #0000ff;">    localhost.tech:registry:5000 = 192.168.93.183:5000</span><br /><br /><span style="color: #0000ff;"># End of [config].</span><br /></div><img src ="http://www.9087120.com/jinq0123/aggbug/215722.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-06-13 14:27 <a href="http://www.9087120.com/jinq0123/archive/2018/06/13/215722.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇?#29825;?/a></div>]]></description></item><item><title>grpc-go涓巃ctor妯?#23534;?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2018/06/12/215720.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215720.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/06/12/215720.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215720.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215720.html</trackback:ping><description><![CDATA[<div>grpc-go涓巃ctor妯?#23534;?br /><br />(閲戝簡鐨勪笓鏍?2018.6)<br /><br />grpc-go鏈?#37716;櫒鐨勬瘡涓?#29831;锋眰閮?#37734;竴涓嫭绔?#37928;?#37719;?#32459;?#28051;?#37813;?#29723;?#37510;?br />缃戞父鏈?#37716;櫒涓?#38171;屼竴鑸?#29831;锋眰浼?#29835;冪敤?#29238;鎴?#37812;块棿鐨勬柟娉曪?#23683;?#37812;块棿鏄竴涓嫭绔?#37928;?#37719;?#32459;?#37510;?br />鍙?#28000;?#28751;?#37812;块棿瀹?#37916;?#28051;actor锛実rpc璇锋眰閫?#26473;Call()鎴朠ost()?#26591;娉?#37833;?#37813;?#29723;?#37510;?br />鍏?#28051;Call()浼氱?#22794;緟杩?#37733;?#38171;岃孭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 鏄?#37711;?#28000;?#37719;?#32459;?#37722;Room鍗?#32459;?#37721;?#38315;?#37716;?#28003;?#37928;Channel锛?#37719;?#32459;?#28051;?#28751;?#28186;?#23046;?#37813;?#29723;屽姩浣?#37510;?/span><br /><span style="color: #800000; font-family: Courier;">    // Action 鍔?#28003;? 鏄?#37827;犲?#20635;?#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;">    // 绛夊?#21615;洿鍒?#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 灏嗕竴涓?#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鏈?#37716;柟娉?#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.9087120.com/jinq0123/aggbug/215720.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-06-12 11:15 <a href="http://www.9087120.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.9087120.com/jinq0123/archive/2018/05/27/215683.html閲戝簡閲戝簡Sun, 27 May 2018 11:22:00 GMThttp://www.9087120.com/jinq0123/archive/2018/05/27/215683.htmlhttp://www.9087120.com/jinq0123/comments/215683.htmlhttp://www.9087120.com/jinq0123/archive/2018/05/27/215683.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215683.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215683.html?#25956; kubeadm --config 鍒涘缓 k8s 闆嗙兢

(閲戝簡鐨勪笓鏍?2018.5)

鍒敤闃?#38322;屼鐨yum闀滃?#24531;拰docker闀滃儚锛屽彲浠?#28051;嶇敤浠?#37918;嗙洿鎺?#28729;?#29761;?#37714;涘缓 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;kubernates-dashboard 1.7瀹?#29761;?br />
https://www.cnblogs.com/liangDream/p/7358847.html
CentOS7.3鍒敤kubeadm瀹?#29761;kubernetes1.7.3瀹屾暣鐗?瀹樻柟鏂囨濉?#37735;戠)

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

Docker ?#20961;瀹?#29761;?#37510;?br />
閲囩敤闃?#38322;屼鐨yum婧?#38336;滃儚锛岀洿鎺?#28729;?#29761;?
yum -y install kubectl kubeadm kubelet

vi /etc/systemd/system/kubelet.service.d/10-kubeadm.conf, 涓簁ubelet?#22346;鍔犱竴涓额澶?#37928;勫?#20635;暟,
杩?#37837;kubelet?#27688;涓嶄?#27692;湪鍚?#37716;pod鐨勬?#36346;欏?#35826;澶?#37928;刱8s浠撳?#25780;?#22794;彇pause-amd64:3.0闀滃儚?#31777;
--pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0

export KUBE_REPO_PREFIX 鐨勬柟寮忔寚瀹歬ube闀滃?#24531;?#25779;凡鍦?.8鐗?#37832;悗鏃?#37825;?#38171;?#38343;瑕?#37824;?#28051;洪厤缃?#37826;?#28000;?#28051;厤缃?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"

鍒濆鍖?#37723;?#28000;?#28051;?#38171;?br />kubeadm init --config kubeadm.yaml

鍏?#28000;?#23049;?#37808;?#37904;?#38171;?br />
闇瑕?#23534;鍚?kubelet.service, 涓嶇劧妫?#29025;浼氭姤?#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

鍙?#28000;煡鐪?ls -ltr /etc/kubernetes/manifests/
yaml鏂?#28000;?#37714;楄锛屾瘡涓?#37826;?#28000;?#38318;?#28028;氬啓?#28483;闀滃儚鐨勫湴鍧鍜岀増鏈?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浼氳嚜鍔?#22955;?#29025;褰?#37715;嶇幆澧?#37828;?#37722;?#37832;?#28051;婃鍛?#28000;?#37813;?#29723;?#37928;?#8220;娈嬬暀”銆?#28641;?#37835;?#37832;?蹇?#26916;?#23059;?#37918;嗗悗鍐嶈?#23678;墽琛宨nit銆?#37812;?#28000;?#37721;?#28000;?#38315;?#26473;?#8221;kubeadm reset”鏉?#23059;?#37918;?#37916;?#28583;?浠?#28598;?#38322;嶆潵銆?br />
journalctl -xeu kubelet
?#25956;鏉煡鐪kubelet鎵?#29723;屾湁浠涔?#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.9087120.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.9087120.com/jinq0123/archive/2018/05/14/215637.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215637.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/05/14/215637.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215637.html</wfw:commentRss><trackback:ping>http://www.9087120.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()?#31476;鏍?#38171;?#26473;?#28051;?#37828;?#29999;?#37833;?#28000;剁紪璇?#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.9087120.com/jinq0123/aggbug/215637.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-05-14 10:42 <a href="http://www.9087120.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;勫嚑涓湴鍧http://www.9087120.com/jinq0123/archive/2018/05/09/215627.html閲戝簡閲戝簡Wed, 09 May 2018 10:32:00 GMThttp://www.9087120.com/jinq0123/archive/2018/05/09/215627.htmlhttp://www.9087120.com/jinq0123/comments/215627.htmlhttp://www.9087120.com/jinq0123/archive/2018/05/09/215627.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215627.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215627.htmlconsul鍛?#28000;?#28051;?#37928;勫嚑涓湴鍧

(閲戝簡鐨勪笓鏍?2018.5)

consul鍛?#28000;?#29723;?#28051;?#37832;?#28000;?#28051;?#37713;?#28051;湴鍧鍙傛暟锛?br />
* -bind
    缁戝?#27692;湴鍧锛岀敤浜庨?#21977;兢閫氫俊锛岀己鐪?0.0.0.0
* -clint
    缁戝?#27692;湴鍧锛岀敤浜?RPC, DNS, HTTP and HTTPS锛岀己鐪?127.0.0.1
* -serf-lan-bind
    缁戝?#27692;湴鍧锛岀敤浜?#37712;?#32515;戦?#21977;兢閫氫俊锛岀己鐪佷?#36328;敤 -bind ?#28276;鍧
* -serf-wan-bind
    缁戝?#27692;湴鍧锛岀敤浜?#29882;?#37832;?#37812;?#38315;氫俊锛岀己鐪佷?#36328;敤 -bind ?#28276;鍧
* -advertise
    閫氬憡?#28276;鍧锛?#38315;氬憡缁?#38342;嗙兢涓?#37711;?#28000;栬妭鐐?#38171;岀己鐪佷?#36328;敤 -bind ?#28276;鍧
* -advertise-wan
    閫氬憡?#28276;鍧锛?#38315;氬憡缁?#37711;?#28000;?#37832;?#37812;?#37928;勬湇鍔妭鐐?#38171;岀己鐪佷?#36328;敤 -advertise ?#28276;鍧
* -join -retry-join
    鍔?#37711;?#38342;嗙兢鐨勭洰鏍囧湴鍧
* -join-wan -retry-join-wan
    璺?#37832;?#37812;块偊鑱?#37928;勭洰鏍囧湴鍧
* -recursor
    涓婃父DNS?#28276;鍧

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


閲戝簡 2018-05-09 18:32 鍙戣璇?#29825;?/a>
]]>鏈?#37716;?#37721;?#37916;?#37928;?#32513;勪欢http://www.9087120.com/jinq0123/archive/2018/05/04/215617.html閲戝簡閲戝簡Fri, 04 May 2018 08:07:00 GMThttp://www.9087120.com/jinq0123/archive/2018/05/04/215617.htmlhttp://www.9087120.com/jinq0123/comments/215617.htmlhttp://www.9087120.com/jinq0123/archive/2018/05/04/215617.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215617.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215617.html

鏈?#37716;?#37721;?#37916;?#37928;?#32513;勪欢

(閲戝簡鐨勪笓鏍?2018.5)

鏈?#37716;?#37721;?#37916;?#37832;?#28000;?#28051;?#32513;勪欢锛?/p>

  • Service Registry 鏈?#37716;?#23049;?#37712;?#28051;?#36423;?/p>

    缁存姢鏈?#37716;?#37928;勫?#26948;锛屾彁渚煡璇?#37510;備竴鑸?#28729;?#37916;?#28051;?#37714;嗗竷寮?#38335;?#37706;?#28699;樺鏁版嵁搴?#37510;?/p>

  • Registrator 娉?#37712;屽櫒

    鐩戝惉鏈?#37716;?#37714;涘缓鍜?#37714;?#38340;?#27996;?#28000;?#38171;屽苟鍦?#37832;?#37716;?#23049;?#37712;?#28051;?#36423;?#37716;?#37804;?#23049;?#37712;?#37812;?#23049;?#38335;鏈?#37716;?#37510;?/p>

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

    鐩?#29785;?#37832;?#37716;?#37828;?#37722;?#37707;?#25652;?#38171;屽苟鍦?#37832;?#37716;?#23049;?#37712;?#28051;?#36423;?#37716;?#37804;?#37831;存柊鏈?#37716;?#37510;?/p>

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

    灏?#37832;?#37716;?#29831;锋眰鍒嗘鍒?#37722;勪釜鏈?#37716;櫒銆?/p>



閲戝簡 2018-05-04 16:07 鍙戣璇?#29825;?/a>
]]>Prometheus鍔?#37804;侀厤缃?#37929;?#37837;?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2018/04/24/215601.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215601.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/04/24/215601.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215601.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215601.html</trackback:ping><description><![CDATA[<div>Prometheus鍔?#37804;侀厤缃?#37929;?#37837;?br /><br />(閲戝簡鐨勪笓鏍?2018.4)<br /><br />鏈绠鍗?#37928;勯厤缃?#37828;?#38344;?#37804;佺洰鏍?#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 />鏇存敼姝?#37826;?#28000;跺悗锛屽彲浠?#37721;?#38315;?SIGHUP 瑙?#37721;戦厤缃?#38322;嶆柊鍔?#26462;?#37510;?br /><br />Prometheus ?#24385;渚涗簡鏈?#37716;?#37721;?#37916;?#37716;熻兘锛屽彲浠?#28000;?consul, dns, kubernetes, file 绛夌瓑澶氱?#23942;潵婧?#37721;?#37916;版柊鐨勭洰鏍?#37510;?br />鍏?#28051;?#37832;绠鍗?#37928;?#37828;?#28000;庢枃浠跺彂鐜?#37832;?#37716;?#37510;?br /><br />渚嬪 /root/prometheus/prometheus.yml ?#21412;缃?#28641;?#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;变?#27699;嚜鍔?#29831;诲彇 test.yml 骞舵坊鍔?#37826;?#37928;勭洰鏍?#37510;?br />鍙敤娴?#29785;堝櫒?#22694;寮Prometheus 9090 绔?#37721;? <br />?#29025;鐪?Status 涓?#37928;?Configuration, Targets, Service Discovery,<br />鍙?#28000;?#37930;?#37714;版?#29256;坊鍔?#37928;勭洰鏍?#37510;?br /></div><img src ="http://www.9087120.com/jinq0123/aggbug/215601.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-04-24 12:13 <a href="http://www.9087120.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.9087120.com/jinq0123/archive/2018/04/19/215597.html閲戝簡閲戝簡Thu, 19 Apr 2018 05:52:00 GMThttp://www.9087120.com/jinq0123/archive/2018/04/19/215597.htmlhttp://www.9087120.com/jinq0123/comments/215597.htmlhttp://www.9087120.com/jinq0123/archive/2018/04/19/215597.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215597.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215597.htmlDocker杩?#29723;孭rometheus鍜孏rafana

(閲戝簡鐨勪笓鏍?2018.4)

Prometheus瀹?#32515;?#37928;?#26473;?#29723;岀渚?#37828;洿鎺?#37813;?#29723;?#37510;?br />鍙?#28000;?#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 濂藉儚涓嶈锛屾崲鎴?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.9087120.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.9087120.com/jinq0123/archive/2018/04/13/215587.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215587.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/04/13/215587.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215587.html</wfw:commentRss><trackback:ping>http://www.9087120.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) 鏄?grpc 鐨?lua 缁戝?#27692;簱锛?br />搴旂敤?#31777; luapbintf , 涓?#38343;瑕佺敓鎴?#28000;爜锛岀洿鎺?#29831;诲彇 proto 鏂?#28000;躲?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 />瀹屾暣鐨勭渚?#28000;爜瑙?examples 鐩綍銆?br /><br />鏈?#37716;櫒鍜?#28729;?#37812;?#32468;?#38318;芥敮鎸?#37722;屾鍜?#23534;傛璋冪敤銆?br /><br />灏?examples/conan_install.bat.example 鍘?#38340;?.example ?#24727;?#32017;锛岀劧?#24727;杩?#29723;?#38171;?br />灏?#28729;?#29761;?#37813;鏈?#37928;勪緷璧?#25652;? 椤?#37711;?#28729;?#29761;?conan 鍖呯鐞嗗伐鍏?(http://docs.conan.io/en/latest/installation.html)銆?br />杩?#38343;瑕?#29825;?#32515;?git 浠?#37918;?#38171;屽洜涓?grpc 鐨勫瓙搴?#38343;瑕佺炕杩?#28583;?#37510;?br /><br />conan_install.bat 瀹為檯涓?#37828;?#28051;嬭浇渚?#29863;?#25652;?#28000;爜骞剁紪璇?#37510;傜粨鏋滃湪?#25956;鎴风洰?#32141; .conan/data/銆?br />鍦?#37711;?#28051;?#37820;滅储 lua-cpp.exe, lua-cpp.dll, luapbintf.dll, grpc_lua.dll 骞?#28598;?#37714;?#37714;?examples/helloworld/ 鐩綍涓?#37510;?br /><br />?#21159;?#24727;鍦?helloworld 鐩綍涓?#37714;?#37714;?#26473;?#29723;?run_server.bat 鍜?run_client.bat 娴?#29831;?#37510;?br /><br /><div>?#20961;缂?#29831;?#23092;?#29831;?#37721;?#29723;?#37928;?#28729;屾暣鍖呭彲涓嬭浇锛?br />grpc-lua 浠爜鍙?#32448;?#28186;媁indows鎵?#29723;?#32459;嬪簭锛歨ttps://download.csdn.net/download/jq0123/10346554<br />grpc-lua 绀?#28186;?CentOS 7.4 鎵?#29723;?#32459;嬪?#24532;墦鍖?#38171;歨ttps://download.csdn.net/download/jq0123/10346003<br /><br />CentOS 7.4 瀹?#23092;?#38171;?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.9087120.com/jinq0123/aggbug/215587.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-04-13 15:41 <a href="http://www.9087120.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.9087120.com/jinq0123/archive/2018/04/08/215577.html閲戝簡閲戝簡Sun, 08 Apr 2018 07:17:00 GMThttp://www.9087120.com/jinq0123/archive/2018/04/08/215577.htmlhttp://www.9087120.com/jinq0123/comments/215577.htmlhttp://www.9087120.com/jinq0123/archive/2018/04/08/215577.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215577.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215577.html?#25956; DocFetcher 鍏?#37826;囨?#28357;储

(閲戝簡鐨勪笓鏍?2018.4)

浠?#37715;嶇敤 Notepad++ 鐨勫叏鏂囨?#28357;储锛屾病鏈夌储寮曪?#23678;?#24532;鎼滅储閮?#26916;?#32475;夊?#21612;竴浼氬効銆?br />
鑰?DocFetcher 鏄?#23534;婧?#37928;勬?#23684;潰鎼滅储搴旂敤锛屽?#21700;?#30028;储寮曞悗锛屾?#28357;储浼氱珛鍗?#37713;虹粨鏋?#37510;?br />
鍏?#26916;?#28051;烘煇涓?#37929;綍鍒涘缓?#20648;寮曪紝閫夋嫨鏌?#27996;涘悗?#32017;鍚?#37928;勬枃浠躲傜劧?#24727;閫?#28051;?#29831;储寮?#26473;涜?#23678;?#28357;储銆?br />

閲戝簡 2018-04-08 15:17 鍙戣璇?#29825;?/a>
]]>缃戞父鏈?#37716;櫒 Services-based 鍜?Cells-based 鏋?#37835;?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2018/03/10/215551.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215551.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/03/10/215551.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215551.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215551.html</trackback:ping><description><![CDATA[<div>缃戞父鏈?#37716;櫒 Services-based 鍜?Cells-based 鏋?#37835;?br /><br />(閲戝簡鐨勪笓鏍?2018.3)<br /><br />鏃?#32514;?#28051;栫晫缃戞父鏈?#37716;櫒鏋?#37835;?#37928;?#29825;?#29825;?#37804;?#29882;?br />http://blog.csdn.net/SmartTony/article/details/6842065<br />?#24385;鍑轰簡2绉嶇?#25118;父鏈?#37716;櫒鏋?#37835;?#38171;?br /><br />* Services-based architecture 鍩?#27996;?#37832;?#37716;?#37928;勬灦鏋?br />* Cells-based architecture 鍩?#27996;巆ell鐨勬灦鏋?br /><br />鍩?#27996;?#37832;?#37716;?#37928;勬灦鏋勬寜鍔熻兘鍒?#37714;?#37812;?#28051;嶅?#23678;湇鍔?#38171;?#28051;嶅?#23678;湇鍔?#28729;?#37916;颁簬涓嶅悓鐨?#26473;涚銆?br />鑰屽熀浜巆ell鐨勬灦鏋勪?#36328;敤鐩?#37722;?#37928;Cell杩涚缁勬垚?#31476;涓?#38342;嗙兢锛屾瘡涓狢ell杩涚鍖?#37722;?#37711;?#38318;?#37928;勫姛?#20824;銆?br /><br />鍩?#27996;?#37832;?#37716;?#37928;勬灦鏋勪竴?#27967;鏄?#28051;?#23092;?#37928;勬灦鏋?#38171;岃嚜浠?microservice 鍜?service mesh 姒?#36423;?#37929;?#32513;?#23092;?#29723;?#38171;?br />鍩?#27996;庡鏈?#37716;?#37928;勬灦鏋勫簲璇?#28028;?#37812;?#28051;?#37832;?#37833;?#37928;勬柟鍚?#37510;?br /><br />鍦?#37827;?#32514;?#28598;湴鍥?#32515;戞父涓?#38171;屽簲璇敤鍩?#27996;巆ell鐨勬灦鏋勬潵瀹?#37916;板湴鍥?#37721;?#37929;?#37711;?#37716;熻兘锛?br />鍏?#28000;?#28051;?#28003;嶇疆鏃?#37711;?#37928;勫姛?#20824;鍒欏簲璇?#28751;?#38322;忔寜鏈?#37716;?#28729;?#37916;?#37510;?br />鑰?#38095;戝埌鏈?#37716;?#37833;?#37733;?#29835;冪敤寤舵椂杈?#28598;?#38171;屽浜?#28729;炴椂鎬?#23534;?#37928;勫姛?#20824;锛屽?#20414;K涔熷簲璇?#37734;cell涓?#28729;?#37916;?#37510;?br /><br />鍙?#28000;?#38000;?#38095;戝鎴?#32468;?#38315;?#26473;囦笓闂?#37928;?#32515;戝叧鏉?#26473;?#37818;cell, 浣跨敤udp/kcp鏉?#37713;忓?#24532;?#36346;?#36530;?br />鑰屽叾浠栭潪瀹炴椂鎬?#37832;?#37716;?#37922;Tcp缃戝?#23456;浆鍙?#37510;?br />鏈?#37716;櫒鍐?#38318;?#37721;?#37711;?#38318;?#32513;熶竴閲囩敤 gRPC.<br /><br /></div><img src ="http://www.9087120.com/jinq0123/aggbug/215551.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-03-10 18:03 <a href="http://www.9087120.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.9087120.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.9087120.com/jinq0123/archive/2018/01/18/215477.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215477.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/01/18/215477.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215477.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215477.html</trackback:ping><description><![CDATA[<div>缃戞父鍚屾涓?#37928;勬椂?#26879;鎰?br /><br />(閲戝簡鐨勪笓鏍?2018.1)<br /><br />?#26882;?#26879;?#29025;瑙紙temporal perception?#32026;:瀵?#28729;?#29785;?#37916;拌薄鐨勫欢缁?#37804;?#37724;岄?#21700;?#24532;?#37928;勫?#23941;簲銆?#28729;為檯涓?#37828;?#28725;?#27996;?#28000;?#37724;?#26473;?#37716;?#37928;勭煡瑙?#37510;?br />-- http://dict.youdao.com/w/temporal_perception<br /><br />缃戞父?#26882;?#26879;浠?#37832;?#37716;櫒鐨勪负鍑?#37510;?br />缃戞父瀹?#37812;?#32468;?#38016;藉悗鏈?#37716;櫒渚嬪1甯椂?#26879;锛屾墍浠?#29723;?#37916;?#37928;?#37828;?#26473;?#37720;?#37928;勫?#28888;櫙銆?br />鍥?#28051;?#37916;?#28729;惰嚜?#38889;鐨勮涓?#37828;凡?#29025;鐨?#38171;屾墍浠?#37832;湴鍙?#28000;预娴嬭嚜?#38889;瑙掕壊鐨勭?#33333;?#38171;岃鍓嶄簬鍏?#28000;?#29785;掕壊銆?br />澶勪簬瓒?#37715;嶆椂?#26879;鐨勪富瑙?#28051;?#28598;勪簬杩?#37720;绘椂?#26879;鐨勫叾浠?#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;勮?#21978;瀹炰綋灞炴?#28028;犳挱<br /><br />涓?#29785;?#37721;?#28000;?#28051;?#26473;?#37720;绘椂?#26879;鐨勫叾浠?#29785;掕壊浜?#27996;?#38171;岃窛绂昏秺杩?#38171;屽彲浠?#37711;?#29825;?#37928;勬?#28850;悗?#26882;?#26879;?#27688;瓒?#38336;?#37510;?br />杩?#28051;?#22994;?#36423;?#32457;颁綔?#26882;?#26879;鎰熺煡杩囨护?#27346;(temporal perception filter)锛?br />鎴?#38000;?#37832;湴鎰熺煡杩囨护?#27346;(local perception filter)銆?br /><br />鍙?#28000;敤鏄?#37828;熶綔绫?#23011;?#38171;?#37812;?#28000;?#37930;?#37714;?#37928;勪竴鍏夊勾杩?#37928;?#37828;?#37828;?#37711;?#28729;?#37828;竴骞?#37715;?#37928;?#37828;?#37828;?#37510;?br /><br />Local Perception Filter Demo<br />http://mikolalysenko.github.io/local-perception-filter-demo/<br /></div><img src ="http://www.9087120.com/jinq0123/aggbug/215477.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-01-18 21:28 <a href="http://www.9087120.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.9087120.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.9087120.com/jinq0123/archive/2018/01/06/215458.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215458.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2018/01/06/215458.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215458.html</wfw:commentRss><trackback:ping>http://www.9087120.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 />鍙?#28000;?#37734;?#23114;氬姩鏉?#37827;?#26440;?#37828;剧?#28888;枃涓?#37813;鏈?#38315;?#28051;?#37928;?#37837;?#29825;?#38171;?br />鍙?#28000;?#38315;?#28051;?#37836;?#28051;?#37721;?#38322;?#37828;剧鏈?#28598;氬?#25117;?#26336;敤銆?#28051;?#26473;?GoClipse 娌?#37832;?"Mark Occurrences" 鍔熻兘銆?br />VS code 鏈夋鍔熻兘銆?br /><br />LiteIDE 瀵?#27996;build閿?#29831;?#28028;?#37828;剧杩?#32457;?#37837;?#29825;?#38171;屾墍浠?#37808;?#29785;夊彲浠?#28186;?#23005;?#28729;?#37916;?Mark Occurrences"銆?br /><br />棣?#37711;?#37813;?#37714;颁簡?#22694;鏍?#29825;?#37928;勫姛?#20824;銆?#37837;?#29825;扮敤鍒伴?#22730;锛屾墍浠?#37820;?QColor', 鎵?#37714;颁簡锛?br />```c++<br />QColor markTypeColor(LiteApi::EditorNaviagteType type)<br />```<br /><br />鐩?#37711;?#37928;勬帴鍙?#28028;氱敤鍒?#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;储鏃朵細鏈夊?#21978;妗嗗湀鍑?#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 />鍙?#37916;?#37922;绘柟妗?#28000;呭湪鍙?#29785;?#37718;哄煙銆?#32513;?#32513;煡鎵?m_findExpression 鍜?m_selectionExpression 鏇存敼澶?#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;?#32491;诲瀷锛?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;板洜鏂板绫诲?#23342;鏇存敼浼?#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;版椂鍏?#23059;?#32460;?#38171;岀劧?#24727;閫?#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;鍚?#39582;?#28051;诲锛?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.9087120.com/jinq0123/aggbug/215458.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2018-01-06 11:05 <a href="http://www.9087120.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.9087120.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.9087120.com/jinq0123/archive/2017/12/25/215444.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215444.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2017/12/25/215444.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215444.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215444.html</trackback:ping><description><![CDATA[<div>gRPC-go 杩?#37818;?#32480;?#37918;?br /><br />(閲戝簡鐨勪笓鏍?2017.12)<br /><br />鎶?example greeter 鏀逛竴涓?#38171;?#28598;?#37918;?SayHello() 璇锋眰?#26882;锛?#28051;?#28000;?#28000;?#26473;?#37733;?#37832;?#23046;?#29831;锋眰鑰?#37928;勫?#23941;瓧锛?br />杩?#26473;?#37733;?#28051;婃璇锋眰鐨勫?#23941;瓧锛屽锛?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 />鏈?#37716;櫒闇瑕?#28051;?#23011;?#28051;?#26473;?#37818;?#28103;?#28699;樺悇?#22172;鐨勬?#29256;嵁銆?#26473;?#37818;?#37714;涘?#28888;椂鍒濆鍖?#37825;版嵁锛?#26473;?#37818;?#37826;?#23534;?#26882;娓?#37918;嗘?#29256;嵁銆?br />杩?#38322;?#37714;敤?#31777;杩?#37818;?#32513;?#29825;?#37928;勬帴鍙?#38171;?#28051;嶇煡閬?#37828;?#37722;?#37828;?#37832;閫?#35120;?#37928;?#28729;?#37916;版柟寮?<br /><br />鏈?#37716;櫒鍒涘?#28888;椂?#22346;鍔?StatsHandler 閫?#26916;?#38171;岃緭鍏竴涓?stats.Handler 鐨?#28729;?#37916;?#37510;?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 闇瀹?#37916;?涓柟娉曪?#23677;彧?#25956;鍒?涓?#26473;?#37818;?#37929;?#37711;?#37928;勬柟娉曪紝TagConn() 鍜?HandleConn(),<br />鍙?#28598;?涓?TagRPC() 鍜?HandleRPC() ?#25956;浜RPC缁?#29825;? 瀹?#37916;?#28051;?#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;墦涓?#37837;?#32475;?#38171;?#28000;?#23005;?#37833;?#37837;?#29831;?#26473;?#37818;?瀹?#37734;?#37828;?#37813;?#28051;嶅嚭杩?#37832;?#28000;涔?#37716;?#23049;?#37833;?#37837;?#29831;?#26473;?#37818;?.</span><br /><span style="color: #800000; font-family: Courier;">// 杩?#28051;?#37837;?#32475;?#37828;?#28051;?#37816;?#38333;?#38171;屽彲淇?#29831;?#23011;?#28051;?#26473;?#37818;敮?#31476;銆?/span><br /><span style="color: #800000; font-family: Courier;">// 灏?#29831;?#37816;?#38333;堟坊鍔?#37714;?#28051;?#28051;?#37826;?#28051;?#37720;?#38171;岄敭涓?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;濮?#37724;岀粨鏉熸椂琚?#29835;冪敤锛?#37714;?#37714;?#28028;?#26440;?#37711;?#28051;嶅悓鐨勭?#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;?#31476;涓猰ap鏉?#32480;?#37918;嗘墍鏈?#26473;?#37818;?#38171;?#28000;?#26473;?#37818;?#37928;?#37837;?#32475;?鏄?#28051;?#37816;?#38333;?涓?#38335;?#38171;屽?#28051;?#28051;婃璇锋眰鑰?#37928;勫?#23941;瓧銆?br />鍥?#28051;?#37832;?#28598;氱绋?#29825;块棶锛屾墍鏈?#37716;?#28051;?Mutex 鏉?#28103;濇姢銆?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;?#37826;?#28051;彇杩?#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 />鏈?#24727;灏?SayHello() 鏀?#28051;?#29825;板綍璇锋眰鑰?#37722;嶅瓧锛屽苟杩?#37733;?#28051;婃璇锋眰鑰?#37928;勫?#23941;瓧銆?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 />娴?#29831;?#28598;?#28051;?#28729;?#37812;?#32468;?#26473;?#37818;?#38171;屽彲浠?#37930;?#37714;?#23011;?#28051;?#28729;?#37812;?#32468;?#37832;夎嚜宸?#37928;勭?#33333;?#38171;屼簰涓嶅?#21342;搷銆?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.9087120.com/jinq0123/aggbug/215444.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2017-12-25 19:00 <a href="http://www.9087120.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.9087120.com/jinq0123/archive/2017/12/07/215397.html閲戝簡閲戝簡Thu, 07 Dec 2017 06:51:00 GMThttp://www.9087120.com/jinq0123/archive/2017/12/07/215397.htmlhttp://www.9087120.com/jinq0123/comments/215397.htmlhttp://www.9087120.com/jinq0123/archive/2017/12/07/215397.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215397.htmlhttp://www.9087120.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() 鍙?#28000;?#27996;?#37922;熶竴涓?#37719;?#32459;?#38171;?#37719;?#32459;?#28051;?#37721;?#28000;?#29835;冪敤 async_read(..., yield), async_write(..., yield), ?#32126;鏄?#28051;嶇煡閬撳浣?#28051;?#37716;?#38322;婃鎺?#37714;?#37833;?yield)?


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


绛?#22935;?#37828;?#38171;?/p>

iosvc.post(yield);


鍏?#28000;?#26473;?#37721;?#28000;?#37828;?/p>

iosvc.poll_one();

iosvc.poll();


搴?#29831;?#37828;?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 鏈?#37716;?/title><link>http://www.9087120.com/jinq0123/archive/2017/11/28/215377.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Tue, 28 Nov 2017 10:47:00 GMT</pubDate><guid>http://www.9087120.com/jinq0123/archive/2017/11/28/215377.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215377.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2017/11/28/215377.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215377.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215377.html</trackback:ping><description><![CDATA[<div>?#25956; Lile 鍒涘缓 gRPC-go 鏈?#37716;?br /><br />(閲戝簡鐨勪笓鏍?2017.11)<br /><br />Lile 鏄竴涓?#23480;?#37711;?#38171;岀敤浜?Go 璇言蹇?#38315;?#37714;涘缓 gRPC 鏈?#37716;?#37510;?br />https://github.com/lileio/lile<br /><br />浼氳嚜鍔坊鍔?Prometheus, Zipkin 鍜?Google PubSub 鏀?#37816;?#37510;?br /><br /><span style="color: #0000ff; font-family: Courier;">go get -u github.com/lileio/lile/...</span><br />灏?#28729;?#29761;?#37813;鏈?#28186;?#29863;?#37718;?#38171;屽苟鐢?#37812;?bin/lile.exe, bin/protoc-gen-lile-server.exe.<br />鍙?#28598;?#26473;?#38343;瑕?#28729;?#29761;?protoc.exe.<br /><br />鎸夌収绀?#28186;?#37714;涘缓 users 鏈?#37716;?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">E:\gopath\src\github.com</span><br /><span style="color: #0000ff; font-family: Courier;">λ lile new jinq0123/users</span><br /><span style="color: #0000ff; font-family: Courier;">Creating project in E:\gopath\src\github.com\jinq0123\users</span><br /><span style="color: #0000ff; font-family: Courier;">Is this OK? [y]es/[n]o</span><br /><span style="color: #0000ff; font-family: Courier;">y</span><br /><span style="color: #0000ff; font-family: Courier;">.</span><br /><span style="color: #0000ff; font-family: Courier;">├── server</span><br /><span style="color: #0000ff; font-family: Courier;">│   ├── server.go</span><br /><span style="color: #0000ff; font-family: Courier;">│   └── server_test.go</span><br /><span style="color: #0000ff; font-family: Courier;">├── subscribers</span><br /><span style="color: #0000ff; font-family: Courier;">│   └── subscribers.go</span><br /><span style="color: #0000ff; font-family: Courier;">├── users</span><br /><span style="color: #0000ff; font-family: Courier;">│   ├── cmd</span><br /><span style="color: #0000ff; font-family: Courier;">│   │   ├── root.go</span><br /><span style="color: #0000ff; font-family: Courier;">│   │   ├── serve.go</span><br /><span style="color: #0000ff; font-family: Courier;">│   │   ├── subscribe.go</span><br /><span style="color: #0000ff; font-family: Courier;">│   │   └── up.go</span><br /><span style="color: #0000ff; font-family: Courier;">│   └── main.go</span><br /><span style="color: #0000ff; font-family: Courier;">├── users.proto</span><br /><span style="color: #0000ff; font-family: Courier;">├── Makefile</span><br /><span style="color: #0000ff; font-family: Courier;">├── Dockerfile</span><br /><span style="color: #0000ff; font-family: Courier;">├── .travis.yml</span><br /><span style="color: #0000ff; font-family: Courier;">└── .gitignore</span><br /><br />?#29025;鐪?Makefile, 澶?#37714;?#37711;?#28051;?protoc 鑴?#37832;?#38171;屽皢 $$GOPATH 鏀?#28051;?%GOPATH%锛?#26473;?#29723;?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">E:\gopath\src\github.com\jinq0123\users</span><br /><span style="color: #0000ff; font-family: Courier;">λ protoc -I . users.proto --lile-server_out=. --go_out=plugins=grpc:%GOPATH%/src</span><br /><span style="color: #0000ff; font-family: Courier;">2017/11/28 16:59:24 [Creating] server\read.go</span><br /><span style="color: #0000ff; font-family: Courier;">2017/11/28 16:59:24 [Creating test] server\read_test.go</span><br /><br />protoc-gen-lile-server.exe 灏?#37922;?#37812;?server\read.go, 瀵瑰簲 user.proto 涓?#37928;勬柟娉?Users::Read().<br />grpc鐨勬彃浠?#28751;?#37922;?#37812;?users.pb.go锛?#28051;?#28000;?#28000;呯敤 grpc 鐢?#37812;?#37928;勪唬鐮佺浉鍚?#37510;?br /><br /><span style="color: #0000ff; font-family: Courier;">D:/Go/bin/go.exe install -v [E:/gopath/src/github.com/jinq0123/users/users]</span><br /><span style="color: #0000ff; font-family: Courier;">github.com/jinq0123/users/users</span><br /><span style="color: #0000ff; font-family: Courier;">鎴?#37716;? 杩涚?#23342;鍑?#28000;爜 0.</span><br /><br />鍙洿鎺?#32514;?#29831;?#37922;?#37812;?user.exe.<br /><br />鏃犲?#20635;暟杩?#29723;?#37714;?#37828;剧?#21700;懡浠?#29723;屽府鍔?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">E:\gopath\src\github.com\jinq0123\users</span><br /><span style="color: #0000ff; font-family: Courier;">λ users</span><br /><span style="color: #0000ff; font-family: Courier;">A gRPC based service</span><br /><br /><span style="color: #0000ff; font-family: Courier;">Usage:</span><br /><span style="color: #0000ff; font-family: Courier;">  users [command]</span><br /><br /><span style="color: #0000ff; font-family: Courier;">Available Commands:</span><br /><span style="color: #0000ff; font-family: Courier;">  help        Help about any command</span><br /><span style="color: #0000ff; font-family: Courier;">  serve       Run the RPC server</span><br /><span style="color: #0000ff; font-family: Courier;">  subscribe   Subscribe to and process queue messages</span><br /><span style="color: #0000ff; font-family: Courier;">  up          up runs both RPC and pubub subscribers</span><br /><br /><span style="color: #0000ff; font-family: Courier;">Flags:</span><br /><span style="color: #0000ff; font-family: Courier;">  -h, --help   help for users</span><br /><br /><span style="color: #0000ff; font-family: Courier;">Use "users [command] --help" for more information about a command.</span><br /><br />?#25956;瀛愬懡浠serve鍚?#37716;?#37832;?#37716;?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">E:\gopath\src\github.com\jinq0123\users</span><br /><span style="color: #0000ff; font-family: Courier;">λ users serve</span><br /><span style="color: #0000ff; font-family: Courier;">INFO[0000] Serving gRPC on :8000</span><br /><span style="color: #0000ff; font-family: Courier;">INFO[0000] Using Zipkin Global tracer</span><br /><span style="color: #0000ff; font-family: Courier;">INFO[0000] Prometheus metrics at :9000/metrics</span><br /><br />http://localhost:9000/metrics 浼?#37828;剧<br /><br /># HELP go_gc_duration_seconds A summary of the GC invocation durations.<br /># TYPE go_gc_duration_seconds summary<br />go_gc_duration_seconds{quantile="0"} 0<br />go_gc_duration_seconds{quantile="0.25"} 0<br />...<br /><br />?#25956; grpc-lua 鏉?#23092;?#29831;?#28051;?#38171;?br /><br /><span style="color: #0000ff; font-family: Courier;">E:\Git\grpc-lua\examples\helloworld (master)</span><br /><span style="color: #0000ff; font-family: Courier;">λ lua-cpp.exe</span><br /><span style="color: #0000ff; font-family: Courier;">Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio</span><br /><span style="color: #0000ff; font-family: Courier;">> package.path = "../../src/lua/?.lua;" .. package.path</span><br /><span style="color: #0000ff; font-family: Courier;">> grpc = require("grpc_lua.grpc_lua")</span><br /><span style="color: #0000ff; font-family: Courier;">> grpc.import_proto_file("users.proto")</span><br /><span style="color: #0000ff; font-family: Courier;">> stub = grpc.service_stub("localhost:8000", "users.Users")</span><br /><span style="color: #0000ff; font-family: Courier;">D1128 17:28:13.711000000  4612 dns_resolver.c:301] Using native dns resolver</span><br /><span style="color: #0000ff; font-family: Courier;">> request = {id = "abcd"}</span><br /><span style="color: #0000ff; font-family: Courier;">> response, err, cod = stub:sync_request("Read", request)</span><br /><span style="color: #0000ff; font-family: Courier;">> cod</span><br /><span style="color: #0000ff; font-family: Courier;">2</span><br /><span style="color: #0000ff; font-family: Courier;">> insp = require("inspect")</span><br /><span style="color: #0000ff; font-family: Courier;">> insp(resonse)</span><br /><span style="color: #0000ff; font-family: Courier;">nil</span><br /><span style="color: #0000ff; font-family: Courier;">> insp(err)</span><br /><span style="color: #0000ff; font-family: Courier;">"not yet implemented"</span><br /><br />缂?#37930;?#28729;?#37916;?#26473;?#37733;?"not yet implemented" 閿?#29831;?#37510;傛?#23384;敼瀹?#37916;?#28000;?#28641;?#28051;?#38171;?br /><br /><span style="color: #800000; font-family: Courier;">func (s UsersServer) Read(ctx context.Context, r *users.Request) (*users.Response, error) {</span><br /><span style="color: #800000; font-family: Courier;">    // return nil, errors.New("not yet implemented")</span><br /><span style="color: #800000; font-family: Courier;">    return &users.Response{Id: "Hello, " + r.Id}, nil</span><br /><span style="color: #800000; font-family: Courier;">}</span><br /><br />鍐嶆璇锋眰锛?br /><br /><span style="color: #0000ff; font-family: Courier;">> response, err, cod = stub:sync_request("Read", request)</span><br /><span style="color: #0000ff; font-family: Courier;">> err</span><br /><span style="color: #0000ff; font-family: Courier;">Endpoint read failed</span><br /><span style="color: #0000ff; font-family: Courier;">...</span><br /><span style="color: #0000ff; font-family: Courier;">> response, err, cod = stub:sync_request("Read", request)</span><br /><span style="color: #0000ff; font-family: Courier;">> err</span><br /><span style="color: #0000ff; font-family: Courier;">nil</span><br /><span style="color: #0000ff; font-family: Courier;">> insp(response)</span><br /><span style="color: #0000ff; font-family: Courier;">{</span><br /><span style="color: #0000ff; font-family: Courier;">  id = "Hello, abcd"</span><br /><span style="color: #0000ff; font-family: Courier;">}</span><br /></div><img src ="http://www.9087120.com/jinq0123/aggbug/215377.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2017-11-28 18:47 <a href="http://www.9087120.com/jinq0123/archive/2017/11/28/215377.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇?#29825;?/a></div>]]></description></item><item><title>protobuf涓?#37928;勬涓剧己鐪佸?#25652;?#29831;?#28051;ENUN_TYPE_UNSPECIFIEDhttp://www.9087120.com/jinq0123/archive/2017/11/22/215364.html閲戝簡閲戝簡Wed, 22 Nov 2017 02:45:00 GMThttp://www.9087120.com/jinq0123/archive/2017/11/22/215364.htmlhttp://www.9087120.com/jinq0123/comments/215364.htmlhttp://www.9087120.com/jinq0123/archive/2017/11/22/215364.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215364.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215364.htmlprotobuf涓?#37928;勬涓剧己鐪佸?#25652;?#29831;?#28051;ENUN_TYPE_UNSPECIFIED

(閲戝簡鐨勪笓鏍?2017.11)

Googol 鍏?#29999;?#37928;?API Design 瑙勮寖涓?#38171;?.proto 涓?#37928;勬涓剧己鐪佸?#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;勬涓剧己鐪佸?#25652;?#29831;?#28051;UNKNOWN
http://blog.csdn.net/jq0123/article/details/52219597


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

?#25956; dep 浠?#37831;?go get 鏉?#38014;峰彇绉?#37832;夊簱


(閲戝簡鐨勪笓鏍?2017.11)


go get 鍔熻兘姣?#26440;?#23534;?#38171;屾棤娉?#38014;峰彇鍒嗘敮锛?#37837;?#32475;?#38171;岀瀹氱増鏈?#38171;宖ork, 鑰?dep 鍙?#28000;?#37707;氬埌銆?code>dep 杩?#37721;?#28000;?#38014;峰彇绉?#37832;夊簱銆?/p>

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

鍙敤锛?/p>

go get -u gitee.com/jinq0123/gogettest

濡?#37835;?#37824;?#28051;?#32457;?#37832;夊簱鍒?#28598;辫触锛?/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;峰彇绉?#37832;夊簱

https://github.com/golang/dep

瀹?#29761;dep

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

鍒濆鍖?/h3>

鍦?#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;朵?#36328;敤 https 鏉?#38014;峰彇 gotgettest 搴?#37510;?

 

娉?#37808;忓簱鍚嶆敼鎴愪簡 jinq012345, 杩?#37837;峰鍏?#38171;?
imort "gitee.com/jinq012345/gogettest"

name鍜宻ource鐨?#29825;?#32515;?#37721;?#37824;?#37816;?#28000;?fork 搴?#38014;峰彇銆?/p>

鑾峰彇gogettest搴?/h3>
dep ensure

浼氬脊鍑?https 鐨勭?#35826;綍?#25956;鎴?#37722;嶅?#23677;?#21977;爜杈?#37711;?#22935;?#37510;?/p>

閲戝簡 2017-11-06 14:27 鍙戣璇?#29825;?/a>
]]>鍑芥暟閿?#29831;?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2017/10/30/215318.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215318.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2017/10/30/215318.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215318.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215318.html</trackback:ping><description><![CDATA[<div>鍑芥暟閿?#29831;?br /><br />(閲戝簡鐨勪笓鏍?2017.10)<br /><br />?#25011;?#22172;锛欸o璇言鍦?#32513;?br />https://shower.im/doc/gopl-zh/ch5/ch5-04.html<br /><br />* 淇?#29831;?#37812;?#37716;?#38171;屾病鏈?#38335;?#29831;?#37510;?br />* 鏃?#23049;?#28103;?#29831;?#37812;?#37716;?#38171;屽IO鎿嶄綔銆?br />    + 杩?#37733;bool, 鍘熷?#29362;彧鏈変竴涓?br />    + 杩?#37733;error<br />    <br />5绉?#38335;?#29831;?#28598;?#37918;嗙?#26667;暐<br />1. 浼犳挱閿?#29831;?br />2. 閲嶈瘯<br />3. ?#31912;鏉?#32459;嬪?#24549;紙鍙?#25652;?#37734;main涓級<br />4. 鏃?#36423;?br />5. 蹇界暐<br /></div><img src ="http://www.9087120.com/jinq0123/aggbug/215318.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2017-10-30 12:22 <a href="http://www.9087120.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.9087120.com/jinq0123/archive/2017/10/26/215308.html閲戝簡閲戝簡Thu, 26 Oct 2017 04:08:00 GMThttp://www.9087120.com/jinq0123/archive/2017/10/26/215308.htmlhttp://www.9087120.com/jinq0123/comments/215308.htmlhttp://www.9087120.com/jinq0123/archive/2017/10/26/215308.html#Feedback0http://www.9087120.com/jinq0123/comments/commentRss/215308.htmlhttp://www.9087120.com/jinq0123/services/trackbacks/215308.html?#25956;docker stack寮鍚痳edis闆嗙兢

(閲戝簡鐨勪笓鏍?2017.10)

鏈?涓猟ocker swarm?#22957;鐐?#38171;?#23534;鍚痳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:

鏁版嵁淇?#28699;?#37826;?#28000;?#37734;?/home/redis/001/data
闆嗙兢?#21412;缃?#37826;?#28000;?#28751;嗕繚瀛?#37714;?/home/redis/001/conf/nodes.conf  
鍚勬?#21700;櫒涓?#37929;綍闇瑕侀?#21227;厛鍒涘缓锛?#28051;嶇劧docker寮鍚?#28598;辫触銆?br />骞?#28051;?#38343;瑕?#29825;?#32515;?#37929;綍鏉?#38340;?#38171;?#28051;嶇劧?#23012;"Permission denied".
redis-server浠敤鎴穟id=100(redis)杩?#29723;?#38171;屾墍浠?br />    chown -R 100 /home/redis/

鍚?#37716;redis鏈?#37716;?#37837;?
    docker stack deploy -c docker-stack.yml redis

redis-server鍚?#37716;悗锛?#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;?#37828;?#28051;?#38171;屽懡浠?#32448;?#28186;嬬己灏?"-it", 浼氭姤閿?#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 娴?#29831;曪紝"-c" 鍙傛暟琛?#32448;?#38342;嗙兢锛屽彲杩?#37818;?#28000;?#37808;忔?#21700;櫒鐨?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鏈?#37716;?#23011;?#26440;冩柟渚?#37510;?br />?#32126;鏄?#37713;?#27996;庢兘鑰?#38095;?#38171;屽簲璇?#32450;佺敤 swarm 鐨凬AT?#27974;鍙戝?#23683;?#29115;浇鍧?#29723;?#37510;?br />鐮?#32460;朵簡涓?#38171;屾?#20635;椂杩?#23052;?#28699;?#28028;?#37510;?br />


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

(閲戝簡鐨勪笓鏍?2017.10)

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

鏍规嵁鍏?#28051;?#37928;勬寚绀?#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;愯嚜宸?#37928;勪富鏈?#37722;?#37812;朓P, 涓嶇劧 passive 鏃?#23049;?#26473;?#37818;?#37510;?br />
2. 杩?#37711;?docker, ?#22346;鍔犱竴涓?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 浼?#29831;?#38338;?#28725;嗙爜銆?br />
濡?#37835;?#37807;?#29781;佹涔?#28103;?#28699;?#28051;?#28028;?#37928;勬枃浠?#38171;?#37714;?#38343;瑕?#37734;docker鍚?#37716;?#28051;坊鍔?#37719;?#37828;犲皠锛?#28051;嶇劧docker鍏?#38338;悗鏂?#28000;跺氨涓嶅瓨鍦簡銆?br />璇?#29785;?#37711;?#28051;?#38171;欿eep user database in a volume




閲戝簡 2017-10-13 20:15 鍙戣璇?#29825;?/a>
]]>Lua鍜孋++涔嬮棿璋冪敤鏁?#37916;?#23092;?#29831;?/title><link>http://www.9087120.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.9087120.com/jinq0123/archive/2017/08/30/215209.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215209.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2017/08/30/215209.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215209.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215209.html</trackback:ping><description><![CDATA[<div>Lua鍜孋++涔嬮棿璋冪敤鏁?#37916;?#23092;?#29831;?br /><br />(閲戝簡鐨勪笓鏍?2017.8)<br /><br />浠跨収 http://www.cnblogs.com/archy_yu/p/3185608.html 瀵?Lua 鍜?C++ 璋冪敤杩涜娴?#29831;?#37510;?br /><br />浠爜瑙?#38171;歨ttps://github.com/jinq0123/TimerLuaIntf<br /><br />浣跨敤 LuaIntf 缁戝畾 Lua 鍜?C++銆傜敤 boost timer 璁?#37827;躲?br />渚?#29863;?#25652;?lua-cpp, lua-intf, boost-timer ?#25956; conan 瀹?#29761;?#37510;?br />conan 浼?#28051;嬭?#33445;?#24878;爜锛岀紪璇?#38171;岀劧?#24727;鐢?#37812;?conanbuildinfo.props 缁?VS 瀵?#37711;?#38171;?br />鍏?#28051;?#29825;?#28610;戒簡鎵鏈?include, lib 鐩?#35120;曪紝閾?#37818;?#25652;?#38171;?#26473;?#29723;屽簱銆?br /><br />浠爜澶?#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 />娴?#29831;?绉嶈?#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 />杈?#37713;哄锛?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;璁?#37828;?#38171;?br />* C++ 璋冪敤 Lua 鍙?#26440;?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.9087120.com/jinq0123/aggbug/215209.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2017-08-30 17:25 <a href="http://www.9087120.com/jinq0123/archive/2017/08/30/215209.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇?#29825;?/a></div>]]></description></item><item><title>琛?#28051;?#37837;?#37928;勪袱绉?#26473;?#29723;屾柟寮?/title><link>http://www.9087120.com/jinq0123/archive/2017/08/26/215197.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Sat, 26 Aug 2017 04:45:00 GMT</pubDate><guid>http://www.9087120.com/jinq0123/archive/2017/08/26/215197.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215197.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2017/08/26/215197.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215197.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215197.html</trackback:ping><description><![CDATA[<div>琛?#28051;?#37837;?#37928;勪袱绉?#26473;?#29723;屾柟寮?br /><br />(閲戝簡鐨勪笓鏍?2017.8)<br /><br />琛?#28051;?#37837;?#23011;?#28051;猅ick杩?#29723;屾湁涓?#32457;?#28729;?#37916;版柟寮?#38171;?br />* 浠?#37837;硅妭鐐?#38322;嶆柊寮濮?#26473;?#29723;?br />* 缁?#32513;?#28051;婃杩?#29723;?#37928;勮妭鐐?br /><br />http://blog.renatopp.com/2014/08/15/an-introduction-to-behavior-trees-part-3/<br /><br />> One common question when implementing a Behavior Tree is that: what to do in the next tick after a node returned a running state? There are two answer to it: starting the graph traversal from the running node or starting it over from the first node.<br /><br />Behavior3 鏄?#23011;忔閮?#28000;?#37837;硅妭鐐?#26473;?#29723;?#37928;?#37510;?#26473;?#32457;?#28729;?#37916;?#32480;鍗曪?#23678;鍦?#26473;?#29723;?#28051;?#37928;勮涓哄彲浠嚜?#21159;?#28276;涓?#23005;?#37714;囨崲鍒?#37711;?#28000;栬涓?#37510;?br /><br />缂?#37904;?#37828;?#23011;忔杩?#29723;?#38318;?#37828;?#38316;嶅?#21976;暣涓?#37837;?#38171;屽浜庡簽澶?#37928;勮涓?#37837;?#38171;屾兘杈冨樊銆?br /><br />http://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php<br /><br />> In the basic implementation of behaviour trees, the system will traverse down from the root of the tree every single frame, testing each node down the tree to see which is active, rechecking any nodes along the way, until it reaches the currently active node to tick it again.<br /><br />> This isn’t a very efficient way to do things, especially when the behaviour tree gets deeper as its developed and expanded during development. I’d say its a must that any behaviour tree you implement should store any currently processing nodes so they can be ticked directly within the behaviour tree engine rather than per tick traversal of the entire tree. <br /><br />Behaviac 瀹?#37916;?#28051;?#32513;?#32513;?#35120;?#37715;嶈妭鐐?#26473;?#29723;?#37510;?br /><br />http://www.behaviac.com/concepts/<br /><br />> 褰撹妭鐐规?#20346;画杩?#37733;?#8220;杩?#29723;?#8221;鐨勬?#36346;?#38171;BT鏍?#37928;勫唴閮?#8220;?#29025;閬?#8221;璇妭鐐?#37828;?#37734;?#37816;佺画“杩?#29723;?#8221;鐨?#38171;?#28000;?#38000;屽湪?#24727;缁?#37928;勬墽琛?#26473;?#32459;?#28051;?#8220;?#27967;鎺?#8221;缁?#32513;?#37813;?#29723;岃?#22957;鐐?#38171;岃?#28051;?#38343;瑕?#28000;?#28598;?#23534;濮?#37813;?#29723;?#38171;岀洿鍒?#29831;?#26473;?#29723;岀?#33333;?#37928;勮妭鐐?#26473;?#37733;?#8220;鎴?#37716;?#8221;鎴?#8220;澶辫触”锛?#28000;?#38000;岀户缁悗缁?#37928;勮妭鐐?#37510;?br /><br />?#32126;鏄?#28051;轰簡澶?#37918;嗕簨浠舵墦鏂?#35120;?#37715;?#26473;?#29723;?#38171;?#38343;瑕?#28598;嶆潅鐨?#28729;?#37916;?#37510;?br /><br />> 濡?#37835;滃彂鐢熶簡鍏?#28000;?#8220;閲嶈”鐨勪?#23339;闇瑕?#28598;?#37918;嗘?#28052;?#37716;?#38171;?br />> 鍦behaviac閲岃嚦灏?#37832;?#28598;氱鍔?#23049;?#37510;?br /><br />鍏?#28003;?#28051;?#38171;?br /><br />* 鍓嶇疆?#22957;鐐?br />* 骞惰?#23683;妭鐐?br />* 鐩?#23092;嬭妭鐐?br />* 浜?#28000;跺瓙鏍?br /><br /></div><img src ="http://www.9087120.com/jinq0123/aggbug/215197.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2017-08-26 12:45 <a href="http://www.9087120.com/jinq0123/archive/2017/08/26/215197.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇?#29825;?/a></div>]]></description></item><item><title>protobuf瀹氫箟浣庡甫瀹?#37928;?#32457;?#37716;?#23057;?#37805;?/title><link>http://www.9087120.com/jinq0123/archive/2017/08/23/215189.html</link><dc:creator>閲戝簡</dc:creator><author>閲戝簡</author><pubDate>Wed, 23 Aug 2017 03:50:00 GMT</pubDate><guid>http://www.9087120.com/jinq0123/archive/2017/08/23/215189.html</guid><wfw:comment>http://www.9087120.com/jinq0123/comments/215189.html</wfw:comment><comments>http://www.9087120.com/jinq0123/archive/2017/08/23/215189.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.9087120.com/jinq0123/comments/commentRss/215189.html</wfw:commentRss><trackback:ping>http://www.9087120.com/jinq0123/services/trackbacks/215189.html</trackback:ping><description><![CDATA[<div>protobuf瀹氫箟浣庡甫瀹?#37928;?#32457;?#37716;?#23057;?#37805;?br /><br />(閲戝簡鐨勪笓鏍?2017.8)<br /><br />?#25956;protobuf瀹氫箟鍗?#29825;椂锛屽彲鍒敤protobuf鐨勭?#26667;爜?#26591;寮忓?#21977;鍔?#23057;?#37805;?#37720;嬬缉鍒?#28751;?#38322;忓皬銆?br /><br /><span style="color: #800000;">service Battle {</span><br /><span style="color: #800000;">    // 绉?#37716;?#37721;?#37718;?#38322;?#37510;?#28751;嗗鎾?#32513;?#37711;?#28000;?#37916;?#28729;?#38171;?#37718;呮嫭?#22172;宸?#37510;?/span><br /><span style="color: #800000;">    // 绉?#37716;?#37721;楁闀块檺鍒躲傝嚜鍔浆鍚?#32457;?#37716;柟鍚?#37510;?/span><br /><span style="color: #800000;">    rpc Move(Movement) returns (rpc.EmptyMsg);</span><br /><span style="color: #800000;">    // ?#27974;鍚?#37832;缁堥潰鍚?#37510;?#28751;嗗鎾?#32513;?#37711;?#28000;?#37916;?#28729;?#38171;?#37718;呮嫭?#22172;宸?#37510;?/span><br /><span style="color: #800000;">    rpc TurnTo(Rotation) returns (rpc.EmptyMsg);</span><br /><span style="color: #800000;">}</span><br /><br /><span style="color: #800000;">// 浣嶇疆锛?#32457;?#37716;?#37724;岃搴?#38318;界敤鏁存暟鍚?#38322;?#29723;?#32448;?#38171;?#37719;?#28003;?#28051;?#37714;嗙背.</span><br /><span style="color: #800000;">// 浣跨敤鏁存暟鍗犵敤鐨勫甫瀹?#23011;?#23092;?#37904;规暟灏?#37510;?/span><br /><span style="color: #800000;">// U3d浣跨敤浠?#32491;?#28051;?#37719;?#28003;?#37928;?#23092;?#37904;规暟锛?#38343;瑕佽浆鍖?#37510;?/span><br /><span style="color: #800000;">message Position {</span><br /><span style="color: #800000;">    optional sint32 x = 1;</span><br /><span style="color: #800000;">    optional sint32 y = 2;</span><br /><span style="color: #800000;">}</span><br /><br /><span style="color: #800000;">// 绉?#37716;?#37827;跺彂閫佺鍔?#38322;?#37510;?#28051;?#37828;?#37721;?#38315;佺粷瀵?#28003;嶇疆锛屼?#36328;敤鏇?#28751;?#37928;勬?#26495;瓧锛?#37719;犵敤鏇?#28751;戝甫瀹?#37510;?/span><br /><span style="color: #800000;">message Movement {</span><br /><span style="color: #800000;">    optional sint32 x = 1;</span><br /><span style="color: #800000;">    optional sint32 y = 2;</span><br /><span style="color: #800000;">}</span><br /><br /><span style="color: #800000;">// 瑙?#25652;?#37722;?#38322;忓湪婊?#29906;崇簿搴?#37928;勫?#23942;彁涓?#38171;屽簲璇?#28751;?#38322;忎?#36328;敤缁?#28725;瑰?#28751;?#37928;勬?#29256;嵁琛?#32448;?#38171;?#37719;犵敤鏇?#28751;戝甫瀹?</span><br /><span style="color: #800000;">message Rotation {</span><br /><span style="color: #800000;">    optional sint32 x = 1;</span><br /><span style="color: #800000;">    optional sint32 y = 2;</span><br /><span style="color: #800000;">}</span><br /><br /><span style="color: #800000;">// 浣嶇疆鍜岄潰鍚?#37510;傜敤浜?#37714;濆鍖?#28725;硅薄銆?/span><br /><span style="color: #800000;">message PosAndRot {</span><br /><span style="color: #800000;">    optional Position position = 1;</span><br /><span style="color: #800000;">    optional Rotation rotation = 2;</span><br /><span style="color: #800000;">}</span><br /><br />璇?#37828;?br /><br />* 鍚嶅瓧鐭?#37904;?#37510;?#37733;?#28051;篟PC娑?#37805;?#28051;?#38343;甯?#37832;?#37716;?#37711;?#37722;嶅?#23678;柟娉?#37722;?#38171;屾墍浠package, service, method鍚嶅?#26948;?#20346;煭鐐?br />* 鍧?#37837;囩敤鏁存暟琛?#32448;?#37510;?#23092;?#37904;?#37825;颁?#27692;浐瀹?#37719;犵敤4涓?#28699;楄妭锛岃?#37818;?#26473;?鍊?#37928;勬?#23384;?#26495;?#37721;?#37719;犵敤涓?#37714;颁竴涓?#28699;楄妭銆?br />* 浣跨敤绉?#37716;?#37721;?#37718;?#38322;?#37510;傚湴鍥?#37721;?#38003;藉緢澶?#38171;岀粷瀵?#37735;?#37837;?#37706;?#26440;?#28598;?#28028;?#37719;犵敤鍙?#28598;氬?#26948;妭锛岃?#32457;?#37716;?#38322;忔?#37828;?#37818;?#26473;?<br />* 瑙?#25652;?#28003;跨敤鍚?#38322;忔洿瀹?#37828;?#28598;?#37918;?#37510;?#28052;熷彲浣跨敤鏁存暟鐨勮搴?#37706;?0-360)琛?#32448;?#38171;屼絾澶?#37918;嗛?#33636;儲銆?br />* 绉?#37716;?#38341;?#37722;簡?#27974;鍚?#37510;傛墍浠浆鍚戞秷鎭?#28051;?#28598;?#38171;?#28051;嶅繀澶?#37734;?#37808;忓灏?#37510;?br />* sint缂栫爜鍘嬬缉鏈澶?#37510;?#29781;佹眰?#28276;鍥?#37735;?#37837;?#25652;?#29831;?#38318;?#37734;?闄?#26473;?#38171;屾璐熷悇鍗?#37510;?br />* 鍗?#28003;?#38315;夋嫨涓嶈澶?#32513;?#38171;?#37714;嗙背鍒板绫?#38318;?#37721;?#28000;?#37510;?/div><img src ="http://www.9087120.com/jinq0123/aggbug/215189.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.9087120.com/jinq0123/" target="_blank">閲戝簡</a> 2017-08-23 11:50 <a href="http://www.9087120.com/jinq0123/archive/2017/08/23/215189.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇?#29825;?/a></div>]]></description></item></channel></rss> <a href="http://www.9087120.com/"><span class="STYLE1">տ3</span></a> <div style="position:fixed;left:-9000px;top:-9000px;"><code id="iceyg"></code><acronym id="iceyg"><div id="iceyg"><tt id="iceyg"></tt></div></acronym><code id="iceyg"><object id="iceyg"><rt id="iceyg"></rt></object></code><samp id="iceyg"></samp><samp id="iceyg"><code id="iceyg"><object id="iceyg"></object></code></samp><sup id="iceyg"></sup><wbr id="iceyg"></wbr><code id="iceyg"><small id="iceyg"><center id="iceyg"></center></small></code><tr id="iceyg"><div id="iceyg"><center id="iceyg"></center></div></tr><acronym id="iceyg"></acronym><xmp id="iceyg"></xmp><acronym id="iceyg"><tt id="iceyg"><code id="iceyg"></code></tt></acronym><samp id="iceyg"><menu id="iceyg"><tt id="iceyg"></tt></menu></samp><optgroup id="iceyg"></optgroup><rt id="iceyg"></rt><center id="iceyg"></center><small id="iceyg"><noscript id="iceyg"><optgroup id="iceyg"></optgroup></noscript></small><samp id="iceyg"><code id="iceyg"><object id="iceyg"></object></code></samp><wbr id="iceyg"></wbr><noscript id="iceyg"><tt id="iceyg"><rt id="iceyg"></rt></tt></noscript><center id="iceyg"></center><center id="iceyg"><center id="iceyg"><small id="iceyg"></small></center></center><samp id="iceyg"></samp><small id="iceyg"></small><optgroup id="iceyg"><noscript id="iceyg"><optgroup id="iceyg"></optgroup></noscript></optgroup><option id="iceyg"></option><small id="iceyg"></small><xmp id="iceyg"></xmp><xmp id="iceyg"></xmp><wbr id="iceyg"><rt id="iceyg"><acronym id="iceyg"></acronym></rt></wbr><tr id="iceyg"></tr><option id="iceyg"></option><code id="iceyg"><small id="iceyg"><noscript id="iceyg"></noscript></small></code><center id="iceyg"></center><xmp id="iceyg"><center id="iceyg"><tr id="iceyg"></tr></center></xmp><div id="iceyg"><noscript id="iceyg"><tr id="iceyg"></tr></noscript></div><small id="iceyg"></small><rt id="iceyg"><sup id="iceyg"><sup id="iceyg"></sup></sup></rt><sup id="iceyg"></sup><code id="iceyg"></code><option id="iceyg"><acronym id="iceyg"><menu id="iceyg"></menu></acronym></option><rt id="iceyg"></rt><noscript id="iceyg"><wbr id="iceyg"><sup id="iceyg"></sup></wbr></noscript><sup id="iceyg"></sup><option id="iceyg"><object id="iceyg"><menu id="iceyg"></menu></object></option><rt id="iceyg"></rt><acronym id="iceyg"></acronym><sup id="iceyg"></sup><xmp id="iceyg"></xmp><object id="iceyg"></object> <rt id="iceyg"><acronym id="iceyg"><menu id="iceyg"></menu></acronym></rt><tt id="iceyg"></tt><code id="iceyg"></code><code id="iceyg"><xmp id="iceyg"><noscript id="iceyg"></noscript></xmp></code><small id="iceyg"><option id="iceyg"><object id="iceyg"></object></option></small><div id="iceyg"><small id="iceyg"><optgroup id="iceyg"></optgroup></small></div><menu id="iceyg"></menu><option id="iceyg"></option><samp id="iceyg"><xmp id="iceyg"><center id="iceyg"></center></xmp></samp><center id="iceyg"><option id="iceyg"><noscript id="iceyg"></noscript></option></center><object id="iceyg"></object><sup id="iceyg"></sup><code id="iceyg"><center id="iceyg"><code id="iceyg"></code></center></code><xmp id="iceyg"></xmp><object id="iceyg"></object><object id="iceyg"></object><sup id="iceyg"></sup><menu id="iceyg"></menu><option id="iceyg"></option><noscript id="iceyg"></noscript><tr id="iceyg"></tr><xmp id="iceyg"></xmp><samp id="iceyg"><xmp id="iceyg"><noscript id="iceyg"></noscript></xmp></samp><div id="iceyg"><noscript id="iceyg"><tr id="iceyg"></tr></noscript></div><rt id="iceyg"></rt><noscript id="iceyg"></noscript><sup id="iceyg"></sup><option id="iceyg"></option><code id="iceyg"><xmp id="iceyg"><noscript id="iceyg"></noscript></xmp></code><object id="iceyg"></object><samp id="iceyg"></samp><tr id="iceyg"></tr><option id="iceyg"><acronym id="iceyg"><menu id="iceyg"></menu></acronym></option><div id="iceyg"></div><tt id="iceyg"></tt><option id="iceyg"></option><option id="iceyg"><acronym id="iceyg"><tt id="iceyg"></tt></acronym></option><tt id="iceyg"></tt><noscript id="iceyg"></noscript><acronym id="iceyg"></acronym><noscript id="iceyg"><tr id="iceyg"><rt id="iceyg"></rt></tr></noscript><wbr id="iceyg"></wbr><code id="iceyg"></code><tt id="iceyg"></tt><tr id="iceyg"></tr><acronym id="iceyg"></acronym><small id="iceyg"></small><wbr id="iceyg"></wbr><center id="iceyg"></center><acronym id="iceyg"></acronym> <tr id="iceyg"><rt id="iceyg"><samp id="iceyg"></samp></rt></tr><tr id="iceyg"></tr><acronym id="iceyg"><sup id="iceyg"><samp id="iceyg"></samp></sup></acronym><tt id="iceyg"></tt><wbr id="iceyg"></wbr><tt id="iceyg"><code id="iceyg"><div id="iceyg"></div></code></tt><sup id="iceyg"><code id="iceyg"><small id="iceyg"></small></code></sup><noscript id="iceyg"><acronym id="iceyg"><tt id="iceyg"></tt></acronym></noscript><tt id="iceyg"></tt><optgroup id="iceyg"></optgroup><noscript id="iceyg"><acronym id="iceyg"><sup id="iceyg"></sup></acronym></noscript><center id="iceyg"></center><tt id="iceyg"></tt><samp id="iceyg"></samp><rt id="iceyg"><tr id="iceyg"><tt id="iceyg"></tt></tr></rt><div id="iceyg"></div><tr id="iceyg"><rt id="iceyg"><samp id="iceyg"></samp></rt></tr><small id="iceyg"></small><wbr id="iceyg"></wbr><sup id="iceyg"></sup><object id="iceyg"></object><rt id="iceyg"></rt><samp id="iceyg"><menu id="iceyg"><center id="iceyg"></center></menu></samp><tt id="iceyg"></tt><small id="iceyg"></small><div id="iceyg"></div><tr id="iceyg"></tr><object id="iceyg"><menu id="iceyg"><code id="iceyg"></code></menu></object><tr id="iceyg"><sup id="iceyg"><samp id="iceyg"></samp></sup></tr><object id="iceyg"></object><wbr id="iceyg"><wbr id="iceyg"><wbr id="iceyg"></wbr></wbr></wbr><small id="iceyg"></small><noscript id="iceyg"></noscript><div id="iceyg"></div><tr id="iceyg"></tr><noscript id="iceyg"><tr id="iceyg"><sup id="iceyg"></sup></tr></noscript><rt id="iceyg"></rt><acronym id="iceyg"><menu id="iceyg"><optgroup id="iceyg"></optgroup></menu></acronym><small id="iceyg"></small><acronym id="iceyg"></acronym><tt id="iceyg"></tt><menu id="iceyg"><optgroup id="iceyg"><div id="iceyg"></div></optgroup></menu><samp id="iceyg"></samp><optgroup id="iceyg"></optgroup><small id="iceyg"></small><option id="iceyg"></option><object id="iceyg"></object><tr id="iceyg"></tr><wbr id="iceyg"></wbr><option id="iceyg"></option></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;"><code id="iceyg"></code><acronym id="iceyg"><div id="iceyg"><tt id="iceyg"></tt></div></acronym><code id="iceyg"><object id="iceyg"><rt id="iceyg"></rt></object></code><samp id="iceyg"></samp><samp id="iceyg"><code id="iceyg"><object id="iceyg"></object></code></samp><sup id="iceyg"></sup><wbr id="iceyg"></wbr><code id="iceyg"><small id="iceyg"><center id="iceyg"></center></small></code><tr id="iceyg"><div id="iceyg"><center id="iceyg"></center></div></tr><acronym id="iceyg"></acronym><xmp id="iceyg"></xmp><acronym id="iceyg"><tt id="iceyg"><code id="iceyg"></code></tt></acronym><samp id="iceyg"><menu id="iceyg"><tt id="iceyg"></tt></menu></samp><optgroup id="iceyg"></optgroup><rt id="iceyg"></rt><center id="iceyg"></center><small id="iceyg"><noscript id="iceyg"><optgroup id="iceyg"></optgroup></noscript></small><samp id="iceyg"><code id="iceyg"><object id="iceyg"></object></code></samp><wbr id="iceyg"></wbr><noscript id="iceyg"><tt id="iceyg"><rt id="iceyg"></rt></tt></noscript><center id="iceyg"></center><center id="iceyg"><center id="iceyg"><small id="iceyg"></small></center></center><samp id="iceyg"></samp><small id="iceyg"></small><optgroup id="iceyg"><noscript id="iceyg"><optgroup id="iceyg"></optgroup></noscript></optgroup><option id="iceyg"></option><small id="iceyg"></small><xmp id="iceyg"></xmp><xmp id="iceyg"></xmp><wbr id="iceyg"><rt id="iceyg"><acronym id="iceyg"></acronym></rt></wbr><tr id="iceyg"></tr><option id="iceyg"></option><code id="iceyg"><small id="iceyg"><noscript id="iceyg"></noscript></small></code><center id="iceyg"></center><xmp id="iceyg"><center id="iceyg"><tr id="iceyg"></tr></center></xmp><div id="iceyg"><noscript id="iceyg"><tr id="iceyg"></tr></noscript></div><small id="iceyg"></small><rt id="iceyg"><sup id="iceyg"><sup id="iceyg"></sup></sup></rt><sup id="iceyg"></sup><code id="iceyg"></code><option id="iceyg"><acronym id="iceyg"><menu id="iceyg"></menu></acronym></option><rt id="iceyg"></rt><noscript id="iceyg"><wbr id="iceyg"><sup id="iceyg"></sup></wbr></noscript><sup id="iceyg"></sup><option id="iceyg"><object id="iceyg"><menu id="iceyg"></menu></object></option><rt id="iceyg"></rt><acronym id="iceyg"></acronym><sup id="iceyg"></sup><xmp id="iceyg"></xmp><object id="iceyg"></object> <rt id="iceyg"><acronym id="iceyg"><menu id="iceyg"></menu></acronym></rt><tt id="iceyg"></tt><code id="iceyg"></code><code id="iceyg"><xmp id="iceyg"><noscript id="iceyg"></noscript></xmp></code><small id="iceyg"><option id="iceyg"><object id="iceyg"></object></option></small><div id="iceyg"><small id="iceyg"><optgroup id="iceyg"></optgroup></small></div><menu id="iceyg"></menu><option id="iceyg"></option><samp id="iceyg"><xmp id="iceyg"><center id="iceyg"></center></xmp></samp><center id="iceyg"><option id="iceyg"><noscript id="iceyg"></noscript></option></center><object id="iceyg"></object><sup id="iceyg"></sup><code id="iceyg"><center id="iceyg"><code id="iceyg"></code></center></code><xmp id="iceyg"></xmp><object id="iceyg"></object><object id="iceyg"></object><sup id="iceyg"></sup><menu id="iceyg"></menu><option id="iceyg"></option><noscript id="iceyg"></noscript><tr id="iceyg"></tr><xmp id="iceyg"></xmp><samp id="iceyg"><xmp id="iceyg"><noscript id="iceyg"></noscript></xmp></samp><div id="iceyg"><noscript id="iceyg"><tr id="iceyg"></tr></noscript></div><rt id="iceyg"></rt><noscript id="iceyg"></noscript><sup id="iceyg"></sup><option id="iceyg"></option><code id="iceyg"><xmp id="iceyg"><noscript id="iceyg"></noscript></xmp></code><object id="iceyg"></object><samp id="iceyg"></samp><tr id="iceyg"></tr><option id="iceyg"><acronym id="iceyg"><menu id="iceyg"></menu></acronym></option><div id="iceyg"></div><tt id="iceyg"></tt><option id="iceyg"></option><option id="iceyg"><acronym id="iceyg"><tt id="iceyg"></tt></acronym></option><tt id="iceyg"></tt><noscript id="iceyg"></noscript><acronym id="iceyg"></acronym><noscript id="iceyg"><tr id="iceyg"><rt id="iceyg"></rt></tr></noscript><wbr id="iceyg"></wbr><code id="iceyg"></code><tt id="iceyg"></tt><tr id="iceyg"></tr><acronym id="iceyg"></acronym><small id="iceyg"></small><wbr id="iceyg"></wbr><center id="iceyg"></center><acronym id="iceyg"></acronym> <tr id="iceyg"><rt id="iceyg"><samp id="iceyg"></samp></rt></tr><tr id="iceyg"></tr><acronym id="iceyg"><sup id="iceyg"><samp id="iceyg"></samp></sup></acronym><tt id="iceyg"></tt><wbr id="iceyg"></wbr><tt id="iceyg"><code id="iceyg"><div id="iceyg"></div></code></tt><sup id="iceyg"><code id="iceyg"><small id="iceyg"></small></code></sup><noscript id="iceyg"><acronym id="iceyg"><tt id="iceyg"></tt></acronym></noscript><tt id="iceyg"></tt><optgroup id="iceyg"></optgroup><noscript id="iceyg"><acronym id="iceyg"><sup id="iceyg"></sup></acronym></noscript><center id="iceyg"></center><tt id="iceyg"></tt><samp id="iceyg"></samp><rt id="iceyg"><tr id="iceyg"><tt id="iceyg"></tt></tr></rt><div id="iceyg"></div><tr id="iceyg"><rt id="iceyg"><samp id="iceyg"></samp></rt></tr><small id="iceyg"></small><wbr id="iceyg"></wbr><sup id="iceyg"></sup><object id="iceyg"></object><rt id="iceyg"></rt><samp id="iceyg"><menu id="iceyg"><center id="iceyg"></center></menu></samp><tt id="iceyg"></tt><small id="iceyg"></small><div id="iceyg"></div><tr id="iceyg"></tr><object id="iceyg"><menu id="iceyg"><code id="iceyg"></code></menu></object><tr id="iceyg"><sup id="iceyg"><samp id="iceyg"></samp></sup></tr><object id="iceyg"></object><wbr id="iceyg"><wbr id="iceyg"><wbr id="iceyg"></wbr></wbr></wbr><small id="iceyg"></small><noscript id="iceyg"></noscript><div id="iceyg"></div><tr id="iceyg"></tr><noscript id="iceyg"><tr id="iceyg"><sup id="iceyg"></sup></tr></noscript><rt id="iceyg"></rt><acronym id="iceyg"><menu id="iceyg"><optgroup id="iceyg"></optgroup></menu></acronym><small id="iceyg"></small><acronym id="iceyg"></acronym><tt id="iceyg"></tt><menu id="iceyg"><optgroup id="iceyg"><div id="iceyg"></div></optgroup></menu><samp id="iceyg"></samp><optgroup id="iceyg"></optgroup><small id="iceyg"></small><option id="iceyg"></option><object id="iceyg"></object><tr id="iceyg"></tr><wbr id="iceyg"></wbr><option id="iceyg"></option></div> <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>