diff --git a/.gitignore b/.gitignore index 9f6baa8..f72d4df 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ debug *.test # Output of the go coverage tool, specifically when used with LiteIDE -*.out \ No newline at end of file +*.out + +.DS_Store \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c881f0..9fe5c01 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,54 @@ "files.trimTrailingWhitespace": true, "files.trimFinalNewlines": true, "go.testFlags": ["-v"], - "go.testTimeout": "100s" + "go.testTimeout": "100s", + + "cSpell.enabledLanguageIds": [ + "csharp", + "go", + "javascript", + "javascriptreact", + "markdown", + "php", + "plaintext", + "text", + "typescript", + "typescriptreact", + "yml" + ], + "cSpell.words": [ + "loafle", + "devtools", + "Checkf", + "IFNULL", + "Nanos", + "Newf", + "Protobuf", + "RPCs", + "Unkeyed", + "adeo", + "amsokol", + "cloudbuild", + "ctxtags", + "ecfg", + "envconfig", + "gcloud", + "genproto", + "glog", + "googleapis", + "grpc", + "gzipped", + "healthz", + "kelseyhightower", + "lmru", + "microservice", + "myid", + "operationlog", + "pgrpc", + "proto", + "protoc", + "ptypes", + "reqid", + "zcfg" + ] } diff --git a/cmd/main.go b/cmd/main.go index 1f82f18..3773cf3 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,35 +1,24 @@ package main -// import ( -// "context" -// "log" -// "net" +import ( + "log" + "net" -// "git.loafle.net/chrome_devtools_protocol/protocol-go/page" -// cdp "git.loafle.net/odds_crawler/odds-crawler-proto/cdp" -// "google.golang.org/grpc" -// ) - -// // server is used to implement helloworld.GreeterServer. -// type server struct{} - -// // SayHello implements helloworld.GreeterServer -// func (s *server) Navigate(ctx context.Context, req *cdp.NavigateRequest) (*cdp.NavigateReply, error) { -// log.Printf("Received: %v", req.Url) - -// page.Navigate() - -// return &cdp.NavigateReply{Message: "Hello " + in.Name}, nil -// } + pkg_cdp "git.loafle.net/odds_crawler/odds-crawler-backend/pkg/v1/cdp" + api_cdp "git.loafle.net/odds_crawler/odds-crawler-proto/pkg/api/v1/cdp" + "google.golang.org/grpc" +) func main() { - // lis, err := net.Listen("tcp", ":50051") - // if err != nil { - // log.Fatalf("failed to listen: %v", err) - // } - // s := grpc.NewServer() - // ocp.RegisterNetworkerServer(s, &server{}) - // if err := s.Serve(lis); err != nil { - // log.Fatalf("failed to serve: %v", err) - // } + lis, err := net.Listen("tcp", ":50051") + if err != nil { + log.Fatalf("failed to listen: %v", err) + } + s := grpc.NewServer() + + api_cdp.RegisterCDPServiceServer(s, pkg_cdp.NewCDPServiceServer()) + + if err := s.Serve(lis); err != nil { + log.Fatalf("failed to serve: %v", err) + } } diff --git a/go.mod b/go.mod index e3df8bf..295efd8 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,27 @@ module git.loafle.net/odds_crawler/odds-crawler-backend go 1.12 require ( - git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511061014-f0ba3e38d8c7 - git.loafle.net/chrome_devtools_protocol/protocol-go v0.0.0-20190511055751-5a1f9a8b45fc - git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190511051133-440e7ba009ca - github.com/golang/protobuf v1.3.1 // indirect - golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09 // indirect + cloud.google.com/go v0.38.0 // indirect + git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511112643-8f164d54e193 + git.loafle.net/chrome_devtools_protocol/protocol-go v0.0.0-20190511082759-e646ea628cc3 + git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190512071153-f53972e2392d + github.com/golang/mock v1.3.0 // indirect + github.com/google/btree v1.0.0 // indirect + github.com/google/go-cmp v0.3.0 // indirect + github.com/google/pprof v0.0.0-20190502144155-8358a9778bd1 // indirect + github.com/hashicorp/golang-lru v0.5.1 // indirect + golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 // indirect + golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522 // indirect + golang.org/x/image v0.0.0-20190507092727-e4e5bf290fec // indirect + golang.org/x/lint v0.0.0-20190409202823-959b441ac422 // indirect + golang.org/x/mobile v0.0.0-20190509164839-32b2708ab171 // indirect + golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect + golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a // indirect golang.org/x/text v0.3.2 // indirect - google.golang.org/appengine v1.4.0 // indirect - google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb // indirect + golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect + golang.org/x/tools v0.0.0-20190511041617-99f201b6807e // indirect + google.golang.org/api v0.5.0 // indirect + google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8 // indirect google.golang.org/grpc v1.20.1 + honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a // indirect ) diff --git a/go.sum b/go.sum index e9624b1..f3439c0 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,34 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511061014-f0ba3e38d8c7 h1:Hb5LqeYN2/DPJd/n+xkfDGKvx55N5qyau3pa3HCO7Ng= git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511061014-f0ba3e38d8c7/go.mod h1:wqIDNOh7UMegLdoxkF53aa4O1zlc4iO+CmyynoHnt+E= git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511062921-d38baf5aeb3b h1:kRsZ4c+Lrnvoowv1sQGx6l/V+Wk7G/nRjdITd7S5ZQU= +git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511082859-88d4eb4529ab h1:1DZD70+4rJm4QP0t1Iu1gvN/gdsdC5qnVS5W7crTCRI= +git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511082859-88d4eb4529ab/go.mod h1:mrYL5lBIWtTQM12qgxHpKrwX4Nvigjvd7GgK3qRJ42I= +git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511100213-aa74964b27cc h1:9vONzIgUOX5l142RqCmzIWHmgqX5vJW5zv/B40/aU5Y= +git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511100213-aa74964b27cc/go.mod h1:mrYL5lBIWtTQM12qgxHpKrwX4Nvigjvd7GgK3qRJ42I= +git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511112643-8f164d54e193 h1:NQK7YdBOOCoC/omORJweVLYksWwI9orDp+AJ8uDIwgk= +git.loafle.net/chrome_devtools_protocol/cdp-go v0.0.0-20190511112643-8f164d54e193/go.mod h1:mrYL5lBIWtTQM12qgxHpKrwX4Nvigjvd7GgK3qRJ42I= git.loafle.net/chrome_devtools_protocol/protocol-go v0.0.0-20190511055751-5a1f9a8b45fc h1:o0G6s1ZPaQX2oW0xCDV+E4OVRRp5F+fnfiOKUhRBX/c= git.loafle.net/chrome_devtools_protocol/protocol-go v0.0.0-20190511055751-5a1f9a8b45fc/go.mod h1:YquKMkEKjSo/hHQDQsoPs5V8zi79klC7/OhehmZekI8= git.loafle.net/chrome_devtools_protocol/protocol-go v0.0.0-20190511062555-aeaa092ca9ac h1:1GQIoMev+gX8QtVZuvDCs4kFkrt54V3MKNWpJcjcHyU= +git.loafle.net/chrome_devtools_protocol/protocol-go v0.0.0-20190511062555-aeaa092ca9ac/go.mod h1:YquKMkEKjSo/hHQDQsoPs5V8zi79klC7/OhehmZekI8= +git.loafle.net/chrome_devtools_protocol/protocol-go v0.0.0-20190511082759-e646ea628cc3 h1:tfs88GChxtmS+fX2FjBNR40R7O/vKdFC8xl8/WSpVRY= +git.loafle.net/chrome_devtools_protocol/protocol-go v0.0.0-20190511082759-e646ea628cc3/go.mod h1:YquKMkEKjSo/hHQDQsoPs5V8zi79klC7/OhehmZekI8= git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190511051133-440e7ba009ca h1:1DZ5z3DinKNYbwdFX15Y6+FZl9SDAg3LmaIso+fTk+c= git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190511051133-440e7ba009ca/go.mod h1:ZCgzl5JJqflmR868uBsp1IGF0Kx4pEvOK4iv+Sh3I1U= +git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190511052236-575e25cfb9f0 h1:pkpW3/j0nUbiNTLozn5CsAgxEE2dWrO7a9iYf0rYXZU= +git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190511052236-575e25cfb9f0/go.mod h1:ZCgzl5JJqflmR868uBsp1IGF0Kx4pEvOK4iv+Sh3I1U= +git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190511092439-c05e19d29705 h1:BES46/oOHWVzFxVRy7YV1vEGnAbppGhW82pdC88+Wb4= +git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190511092439-c05e19d29705/go.mod h1:ZCgzl5JJqflmR868uBsp1IGF0Kx4pEvOK4iv+Sh3I1U= +git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190512060301-d5032ce99abc h1:fWcouC6DJI3h6V3bANnyDnl6iRJcNhxPJCM+cmqH+cM= +git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190512070752-8d4bf386c219 h1:pFSpOk0BgnH/DC29pBc21ActXrF77RxwXcuxjWmdOus= +git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190512070752-8d4bf386c219/go.mod h1:ZCgzl5JJqflmR868uBsp1IGF0Kx4pEvOK4iv+Sh3I1U= +git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190512071153-f53972e2392d h1:4hV6KQ2az7I3GT1v9s4JJLvEf+6v7Rn501Ww9+hlSkQ= +git.loafle.net/odds_crawler/odds-crawler-proto v0.0.0-20190512071153-f53972e2392d/go.mod h1:ZCgzl5JJqflmR868uBsp1IGF0Kx4pEvOK4iv+Sh3I1U= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= @@ -18,49 +39,102 @@ github.com/gobwas/ws v1.0.0/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.0/go.mod h1:c8YoAQJ7+qIz9IQm9G72MJ4uDcrPeLjkrQ4yYIHdhyw= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190502144155-8358a9778bd1/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307 h1:vl4eIlySbjertFaNwiMjXsGrFVK25aOWLq7n+3gh2ls= github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307/go.mod h1:BjPj+aVjl9FW/cCGiF3nGh5v+9Gd3VCgBQbod/GlMaQ= github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 h1:wL11wNW7dhKIcRCHSm4sHKPWz0tt4mwBsVodG7+Xyqg= github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190424203555-c05e17bb3b2d/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190507092727-e4e5bf290fec/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190509164839-32b2708ab171/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09 h1:KaQtG+aDELoNmXYas3TVkGNYRuq8JQ1aa7LJt8EXVyo= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 h1:6M3SDHlHHDCx2PcQw3S4KsR170vGqDhJDOmpVd4Hjak= +golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190425145619-16072639606e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872 h1:cGjJzUd8RgBw428LXP65YXni0aiGNA4Bl+ls8SmLOm8= golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190511041617-99f201b6807e/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.5.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb h1:i1Ppqkc3WQXikh8bXiwHqAN5Rv3/qDCcRk0/Otx73BY= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8 h1:x913Lq/RebkvUmRSdQ8MNb0GZKn+SR1ESfoetcQSeak= +google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/pkg/cdp/service/v1/cdp-service.go b/pkg/cdp/service/v1/cdp-service.go deleted file mode 100644 index 10c6ce1..0000000 --- a/pkg/cdp/service/v1/cdp-service.go +++ /dev/null @@ -1,66 +0,0 @@ -package cdp - -import ( - "context" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "git.loafle.net/chrome_devtools_protocol/cdp-go/pkg/cdp" - "git.loafle.net/chrome_devtools_protocol/protocol-go/pkg/page" - v1 "git.loafle.net/odds_crawler/odds-crawler-proto/pkg/api/v1" -) - -const ( - // apiVersion is version of API is provided by server - apiVersion = "v1" -) - -// cdpServiceServer is implementation of v1.CDPServiceServer proto interface -type cdpServiceServer struct { - ctx context.Context - cancel context.CancelFunc -} - -// NewCDPServiceServer creates ToDo service -func NewCDPServiceServer() v1.CDPServiceServer { - ctx, cancel := cdp.NewContext(context.Background()) - - return &cdpServiceServer{ - ctx: ctx, - cancel: cancel, - } -} - -func (s *cdpServiceServer) checkAPI(api string) error { - // API version is "" means use current version of the service - if len(api) > 0 { - if apiVersion != api { - return status.Errorf(codes.Unimplemented, - "unsupported API version: service implements API version '%s', but asked for '%s'", apiVersion, api) - } - } - return nil -} - -func (s *cdpServiceServer) Navigate(ctx context.Context, req *v1.NavigateRequest) (*v1.NavigateReply, error) { - if err := s.checkAPI(req.Api); err != nil { - return nil, err - } - - params := page.Navigate(req.Url) - params.WithReferrer(req.Referrer) - params.WithTransitionType(req.TransitionType) - params.WithFrameID(req.FrameID) - - frameID, loaderID, errorText, err := params.Do(s.ctx) - if nil != err { - return nil, err - } - - return &v1.NavigateReply{ - FrameID: frameID, - LoaderID: loaderID, - ErrorText: errorText, - }, nil -} diff --git a/pkg/v1/cdp/cdp-service.go b/pkg/v1/cdp/cdp-service.go new file mode 100644 index 0000000..9d5195d --- /dev/null +++ b/pkg/v1/cdp/cdp-service.go @@ -0,0 +1,86 @@ +package cdp + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + _cdp "git.loafle.net/chrome_devtools_protocol/cdp-go/pkg/cdp" + "git.loafle.net/chrome_devtools_protocol/protocol-go/pkg/cdp" + "git.loafle.net/chrome_devtools_protocol/protocol-go/pkg/page" + api_cdp "git.loafle.net/odds_crawler/odds-crawler-proto/pkg/api/v1/cdp" +) + +const ( + // apiVersion is version of API is provided by server + apiVersion = "v1" +) + +// cdpServiceServer is implementation of v1.CDPServiceServer proto interface +type cdpServiceServer struct { + ctx context.Context + cancel context.CancelFunc +} + +// NewCDPServiceServer creates ToDo service +func NewCDPServiceServer() api_cdp.CDPServiceServer { + + ctx, cancel := _cdp.NewContext( + context.Background(), + ) + + return &cdpServiceServer{ + ctx: ctx, + cancel: cancel, + } +} + +func (s *cdpServiceServer) checkAPI(api string) error { + // API version is "" means use current version of the service + if len(api) > 0 { + if apiVersion != api { + return status.Errorf(codes.Unimplemented, + "unsupported API version: service implements API version '%s', but asked for '%s'", apiVersion, api) + } + } + return nil +} + +func (s *cdpServiceServer) Navigate(ctx context.Context, req *api_cdp.NavigateRequest) (*api_cdp.NavigateReply, error) { + if err := s.checkAPI(req.Api); err != nil { + return nil, err + } + + var res *api_cdp.NavigateReply + + err := + _cdp.Run(s.ctx, + _cdp.Tasks{ + _cdp.ActionFunc(func(ctx context.Context) error { + params := page.Navigate(req.Url) + params.WithReferrer(req.Referrer) + params.WithTransitionType(page.TransitionType(req.TransitionType)) + params.WithFrameID(cdp.FrameID(req.FrameID)) + + frameID, loaderID, errorText, err := params.Do(s.ctx) + if nil != err { + return err + } + + res = &api_cdp.NavigateReply{ + FrameID: frameID.String(), + LoaderID: loaderID.String(), + ErrorText: errorText, + } + return nil + }), + }, + ) + + if nil != err { + return nil, err + } + + return res, nil +}