2つのスタイルの並行処理
- CSPモデル
- プロセス間で直接相互通信をしない (?)
- Goでは独立したプロセスとしてゴルーチンを使い、相互通信のためにチャネルを用いる(?)
- 伝統的な共有メモリマルチスレッディング
- 他の言語では一般的にスレッドが使われる
- Ch.9で取り扱う
| package main | |
| import ( | |
| "testing" | |
| ) | |
| type User struct { | |
| ID int | |
| a int | |
| b int64 |
| #!/bin/bash | |
| # Read user_id from list.txt and executes query to ES. | |
| # Usage: | |
| # $ bash exec.sh list.txt | |
| HOST='http://localhost:9200' | |
| INDEX='index_name_1,index_name_2,my_awesome_index' | |
| LIMIT=1000 | |
| OUTPUT='[.user_id, .status]' # jq expression |
2つのスタイルの並行処理
| // Copyright 2016 LINE Corporation | |
| // | |
| // LINE Corporation licenses this file to you under the Apache License, | |
| // version 2.0 (the "License"); you may not use this file except in compliance | |
| // with the License. You may obtain a copy of the License at: | |
| // | |
| // http://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| class Action { | |
| constructor(req, res){ | |
| this.request = req; | |
| this.response = res; | |
| this.requestSource = (req.body.originalRequest) ? req.body.originalRequest.source : undefined; | |
| this.app = new DialogflowApp({req, res}); | |
| console.log('api-v2') | |
| } |