
ã¯ã©ãŠããã¯ãããžãŒããã³Kubernetesã®è©å€ã®é«ãå°é家ã§ããBrendan Burnsã¯ããã®å°ããªäœæ¥ã§ãåæ£ã·ã¹ãã ã®é©åãªèšèšã«å¿ èŠãªçµ¶å¯Ÿçãªæå°å€ãèšå®ããŸãã ãã®æ¬ã¯ãåæ£ã·ã¹ãã ãèšèšããæ代ãè¶ ãããã¿ãŒã³ã«ã€ããŠèª¬æããŠããŸãã ãã®ãããªã·ã¹ãã ããŒãããäœæããã ãã§ãªããæ¢åã®ã·ã¹ãã ãå¹æçã«å€æããã®ã«ã圹ç«ã¡ãŸãã
æç² ãã³ã¬ãŒã¿ãã¿ãŒã³ã ãªã¯ãšã¹ããŸãã¯ã¬ã¹ãã³ã¹ãå€æãã
FaaSã¯ãå ¥åããŒã¿ãåŠçããŠä»ã®ãµãŒãã¹ã«è»¢éããåçŽãªæ©èœãå¿ èŠãªå Žåã«çæ³çã§ãã ãã®çš®é¡ã®ãã¿ãŒã³ã¯ãå¥ã®ãµãŒãã¹ã«ãã£ãŠéä¿¡ãŸãã¯åä¿¡ãããHTTPèŠæ±ãå±éãŸãã¯è£ 食ããããã«äœ¿çšã§ããŸãã ãã®ãã¿ãŒã³ãå³ã«æŠç¥çã«ç€ºããŸãã 8.1ã
ãšããã§ãããã°ã©ãã³ã°èšèªã§ã¯ããã®ãã¿ãŒã³ã«ããã€ãã®é¡æšããããŸãã ç¹ã«ãPythonã«ã¯ãèŠæ±ãŸãã¯å¿çãã³ã¬ãŒã¿ãŒãšæ©èœçã«é¡äŒŒããé¢æ°ãã³ã¬ãŒã¿ãŒããããŸãã è£ é£Ÿå€æã¯ç¶æ ãä¿åããããµãŒãã¹ã®éçºæã«äºå®äžè¿œå ãããããšãå€ããããFaaSãšããŠã®å®è£ ã«æé©ã§ãã ããã«ãFaaSã®è»œãã¯ããµãŒãã¹ãšããå¯æ¥ã«çµ±åãããã³ã¬ãŒã¿ãŒãèŠã€ãããŸã§ãããŸããŸãªãã³ã¬ãŒã¿ãŒãè©Šãããšãã§ããããšãæå³ããŸãã

HTTP RESTful APIãªã¯ãšã¹ãã®å ¥åãã©ã¡ãŒã¿ãŒã«ããã©ã«ãå€ãè¿œå ãããšãDecoratorãã¿ãŒã³ã®å©ç¹ãå®èšŒãããŸãã å€ãã®APIãªã¯ãšã¹ãã«ã¯ãåŒã³åºãå ã«ãã£ãŠæå®ãããŠããªãå Žåãé©åãªå€ãå ¥åããå¿ èŠããããã£ãŒã«ãããããŸãã ããšãã°ããã£ãŒã«ããããã©ã«ãã®trueã«èšå®ããŸãã ããã©ã«ãã®ç©ºã®ãã£ãŒã«ãå€ã¯nullã§ãããéåžžã¯falseãšè§£éããããããåŸæ¥ã®JSONã§ã¯ãããå®çŸããã®ãå°é£ã§ãã ãã®åé¡ã解決ããã«ã¯ãAPIãµãŒããŒã®åãŸãã¯ã¢ããªã±ãŒã·ã§ã³èªäœã®ã³ãŒãã«ããã©ã«ãå€ãä»£å ¥ããããžãã¯ãè¿œå ããŸãïŒããšãã°ãïŒfield == nullïŒfield = trueïŒã ãã ãããããã®ã¢ãããŒãã¯ã©ã¡ããæé©ã§ã¯ãããŸãããããã¯ãããã©ã«ãã®çœ®æã¡ã«ããºã ãæŠå¿µçã«ãªã¯ãšã¹ãåŠçããç¬ç«ããŠããããã§ãã 代ããã«ãFaaS Decoratorãã¿ãŒã³ã䜿çšããŠããŠãŒã¶ãŒãšãµãŒãã¹å®è£ ã®éã®éäžã§ãªã¯ãšã¹ããå€æã§ããŸãã
åäžããŒããã¿ãŒã³ã®ã»ã¯ã·ã§ã³ã§åè¿°ããå 容ãèæ ®ãããšãã¢ããã¿ãŒã³ã³ãããŒã®åœ¢åŒã§æ¢å®ã®çœ®æãµãŒãã¹ãèšèšããªãã£ãçç±ãçåã«æããããããŸããã ãã®ã¢ãããŒãã¯çã«ããªã£ãŠããŸãããããã©ã«ãã®ã«ãã¯ã¢ãããµãŒãã¹ã®ã¹ã±ãŒãªã³ã°ãšAPIãµãŒãã¹èªäœã®ã¹ã±ãŒãªã³ã°ãäºãã«äŸåããããã«ãªãããšãæå³ããŸãã ããã©ã«ãå€ã眮ãæããããšã¯èšç®äžç°¡åãªæäœã§ãããå€ãã®å ŽåããµãŒãã¹ã®å€ãã®ã€ã³ã¹ã¿ã³ã¹ã¯å¿ èŠãããŸããã
ãã®ç« ã®äŸã§ã¯ãkubeless FaaSãã¬ãŒã ã¯ãŒã¯ïŒhttps://github.com/kubeless/kubelessïŒã䜿çšããŸãã Kubelessã¯ãKubernetesã³ã³ãããªãŒã±ã¹ãã¬ãŒã¿ãŒãµãŒãã¹ã®äžã«å±éãããŸãã ãã§ã«Kubernetesã¯ã©ã¹ã¿ãŒãæºåããŠããå Žåã¯ã察å¿ãããµã€ãïŒhttps://github.com/kubeless/kubeless/releasesïŒããããŠã³ããŒãã§ããKubelessã®ã€ã³ã¹ããŒã«ã«é²ã¿ãŸãã kubelesså®è¡å¯èœãã¡ã€ã«ãå ¥æããããkubeless installã³ãã³ãã䜿çšããŠã¯ã©ã¹ã¿ãŒã«ã€ã³ã¹ããŒã«ã§ããŸãã
Kubelessã¯ããµãŒãããŒãã£ã®Kubernetes APIã¢ããªã³ãšããŠã€ã³ã¹ããŒã«ãããŸãã ããã¯ãã€ã³ã¹ããŒã«åŸã«kubectlã³ãã³ãã©ã€ã³ããŒã«ã®äžéšãšããŠäœ¿çšã§ããããšãæå³ããŸãã ããšãã°ãã¯ã©ã¹ã¿ãŒã«ãããã€ãããé¢æ°ã¯ãkubectl get functionsã³ãã³ããå®è¡ããããšã§ç¢ºèªã§ããŸãã çŸåšãã¯ã©ã¹ã¿ãŒã«ãããã€ãããŠããæ©èœã¯ãããŸããã
ã¯ãŒã¯ã·ã§ãã èŠæ±åŠçåã®ããã©ã«ãå€ã®çœ®æ
ãŠãŒã¶ãŒãå€ãèšå®ããŠããªããã©ã¡ãŒã¿ãŒãRESTfulåŒã³åºãã§ããã©ã«ãå€ã«çœ®ãæããäŸã«ãããFaaSã®Decoratorãã¿ãŒã³ã®æçšæ§ãå®èšŒã§ããŸãã FaaSã§ã¯ãããã¯éåžžã«ç°¡åã§ãã ããã©ã«ãã®ã«ãã¯ã¢ããé¢æ°ã¯Pythonã§æžãããŠããŸãïŒ
# -, # def handler(context): # obj = context.json # "name" , # if obj.get("name", None) is None: obj["name"] = random_name() # 'color', # 'blue' if obj.get("color", None) is None: obj["color"] = "blue" # API- # # return call_my_api(obj)
ãã®é¢æ°ãdefaults.pyãšãããã¡ã€ã«ã«ä¿åããŸãã call_my_apiåŒã³åºãããå¿ èŠãªAPIã®åŒã³åºãã«çœ®ãæããŠãã ããã ãã®ããã©ã«ãã®çœ®æé¢æ°ã¯ã次ã®ã³ãã³ãã䜿çšããŠkubelessé¢æ°ãšããŠç»é²ã§ããŸãã
kubeless function deploy add-defaults \ --runtime python27 \ --handler defaults.handler \ --from-file defaults.py \ --trigger-http
ãã¹ãããã«ã¯ãkubelessããŒã«ã䜿çšã§ããŸãã
kubeless function call add-defaults --data '{"name": "foo"}'
ãã³ã¬ãŒã¿ãã¿ãŒã³ã¯ãããã©ã«ãå€ã®æ€èšŒã眮æãªã©ã®è¿œå æ©èœã䜿çšããŠãæ¢åã®APIãç°¡åã«èª¿æŽããã³æ¡åŒµã§ããããšã瀺ããŠããŸãã
ã€ãã³ãåŠç
ã»ãšãã©ã®ã·ã¹ãã ã¯ã¯ãšãªæåã§ã-ãŠãŒã¶ãŒãšAPIãªã¯ãšã¹ãã®é£ç¶ãããŒãåŠçããŸãã ããã«ãããããããã€ãã³ãæåã®ã·ã¹ãã ã¯ããªããããŸãã ç§ã«ãšã£ãŠã¯ããªã¯ãšã¹ããšã€ãã³ãã®éãã¯ã»ãã·ã§ã³ã®ã³ã³ã»ããã«ãããŸãã èŠæ±ã¯ããã倧ããªå¯Ÿè©±ããã»ã¹ïŒã»ãã·ã§ã³ïŒã®äžéšã§ãã äžè¬çãªå ŽåãåãŠãŒã¶ãŒãªã¯ãšã¹ãã¯ãWebã¢ããªã±ãŒã·ã§ã³ãŸãã¯APIå šäœãšããåãããããã»ã¹ã®äžéšã§ãã ç§ã¯ãã€ãã³ããæ¬è³ªçã«éåæã®ãã¯ã³ã¿ã€ã ããšèŠãªããŠããŸãã ã€ãã³ãã¯éèŠã§ãããããã«å¿ããŠåŠçããå¿ èŠããããŸãããã€ãã³ãã¯çžäºäœçšã®äž»èŠãªã³ã³ããã¹ãããåãé¢ãããŠããããããã«å¯Ÿããçãã¯ãã°ããããŠããæ¥ãŸãã ã€ãã³ãã®äŸãšããŠã¯ãç¹å®ã®ãµãŒãã¹ãžã®ãŠãŒã¶ãŒã®ãµãã¹ã¯ãªãã·ã§ã³ããããŸããããã«ãããã°ãªãŒãã£ã³ã°ã¬ã¿ãŒãéä¿¡ãããŸãã å ±æãã©ã«ããŒã«ãã¡ã€ã«ãã¢ããããŒããããšããã®ãã©ã«ããŒã®ãã¹ãŠã®ãŠãŒã¶ãŒã«éç¥ãéä¿¡ãããŸãã ãŸãã¯ãåèµ·åã®ããã«ã³ã³ãã¥ãŒã¿ãŒãæºåããŸããããã«ãããé©åãªã¢ã¯ã·ã§ã³ãå¿ èŠã§ããããšããªãã¬ãŒã¿ãŒãŸãã¯èªåã·ã¹ãã ã«éç¥ããŸãã
ãããã®ã€ãã³ãã¯ã»ãšãã©ç¬ç«ããŠãããå éšç¶æ ããªããé »åºŠãéåžžã«å€åãããããã€ãã³ãæåã®FaaSã¢ãŒããã¯ãã£ã§ã®äœæ¥ã«æé©ã§ãã å€ãã®å Žåãè¿œå ã®æ©èœãæäŸããããããŸãã¯æ°ããªã€ãã³ãã«å¿ããŠããŒã¿ãããã¯ã°ã©ãŠã³ãã§åŠçããããã«ããæŠéãã¢ããªã±ãŒã·ã§ã³ãµãŒããŒã®é£ã«é 眮ãããŸãã ããã«ãæ°ããã¿ã€ãã®åŠçæžã¿ã€ãã³ããåžžã«ãµãŒãã¹ã«è¿œå ããããããæ©èœã®å±éã容æãªãããã€ãã³ããã³ãã©ãŒã®å®è£ ã«é©ããŠããŸãã ãŸããåã€ãã³ãã¯æŠå¿µçã«ä»ã®ã€ãã³ãããç¬ç«ããŠãããããæ©èœã«åºã¥ããŠæ§ç¯ãããã·ã¹ãã å ã®é¢ä¿ã匷å¶çã«åŒ±ããããšã«ãããæŠå¿µã®è€éãã軜æžã§ããéçºè ã¯ç¹å®ã®ã¿ã€ãã®ã€ãã³ãã®ã¿ãåŠçããããã«å¿ èŠãªæé ã«éäžã§ããŸãã
ã€ãã³ãæåã³ã³ããŒãã³ããæ¢åã®ãµãŒãã¹ã«çµ±åããç¹å®ã®äŸã¯ã2èŠçŽ èªèšŒã®å®è£ ã§ãã ãã®å Žåãã€ãã³ãã¯ãŠãŒã¶ãŒã®ã·ã¹ãã ãžã®ãã°ã€ã³ã«ãªããŸãã ãµãŒãã¹ã¯ãã®ã¢ã¯ã·ã§ã³ã®ã€ãã³ããçæãããã³ãã©ãŒé¢æ°ã«æž¡ãããšãã§ããŸãã ãã³ãã©ãŒã¯ãéä¿¡ãããã³ãŒããšãŠãŒã¶ãŒã®é£çµ¡å æ å ±ã«åºã¥ããŠãããã¹ãã¡ãã»ãŒãžã®åœ¢åŒã§èªèšŒã³ãŒããéä¿¡ããŸãã
ã¯ãŒã¯ã·ã§ãã 2èŠçŽ èªèšŒã®å®è£
äºèŠçŽ èªèšŒã¯ãã·ã¹ãã ã«å ¥ãã«ã¯ããŠãŒã¶ãŒãç¥ã£ãŠãããã®ïŒãã¹ã¯ãŒããªã©ïŒãšæã£ãŠãããã®ïŒé»è©±çªå·ãªã©ïŒãå¿ èŠã§ããããšã瀺ããŸãã æ»æè ã¯ã¢ã¯ã»ã¹ããããã«ãã¹ã¯ãŒããšé»è©±çªå·ã®äž¡æ¹ãçãå¿ èŠãããããã2èŠçŽ èªèšŒã¯åãªããã¹ã¯ãŒããããã¯ããã«åªããŠããŸãã
2èŠçŽ èªèšŒã®å®è£ ãèšç»ããå Žåãã©ã³ãã ã³ãŒããçæããããã®ãªã¯ãšã¹ããåŠçãããã°ã€ã³ãµãŒãã¹ã«ç»é²ããŠããŠãŒã¶ãŒã«ã¡ãã»ãŒãžãéä¿¡ããå¿ èŠããããŸãã ãã®æ©èœãå®è£ ããã³ãŒãããã°ã€ã³ãµãŒãã¹èªäœã«çŽæ¥è¿œå ã§ããŸãã ããã«ããã·ã¹ãã ãè€éã«ãªããã¢ããªã·ãã¯ã«ãªããŸãã ã¡ãã»ãŒãžã®éä¿¡ã¯ããã°ã€ã³WebããŒãžãçæããã³ãŒããšåæã«å®è¡ããå¿ èŠããããŸããããã«ãããäžå®ã®é 延ãçããå ŽåããããŸãã ãã®é 延ã¯ãã·ã¹ãã ãšã®ãŠãŒã¶ãŒã€ã³ã¿ã©ã¯ã·ã§ã³ã®å質ãäœäžãããŸãã
ä¹±æ°ãéåæçã«çæãããã°ã€ã³ãµãŒãã¹ã«ç»é²ããŠãŠãŒã¶ãŒã®é»è©±ã«éä¿¡ããFaaSãµãŒãã¹ãäœæããããšããå§ãããŸãã ãããã£ãŠããã°ã€ã³ãµãŒããŒã¯ãFaaSãµãŒãã¹ãžã®éåæãªã¯ãšã¹ããå®è¡ããã ãã§æžã¿ãã³ãŒãã®ç»é²ãšéä¿¡ãšããæ¯èŒçé ãã¿ã¹ã¯ã䞊è¡ããŠå®è¡ããŸãã
ãããã©ã®ããã«æ©èœãããã確èªããã«ã¯ã次ã®ã³ãŒããæ€èšããŠãã ããã
def two_factor(context): # code = random.randint(1 00000, 9 99999) # user = context.json["user"] register_code_with_login_service(user, code) # Twillio account = "my-account-sid" token = "my-token" client = twilio.rest.Client(account, token) user_number = context.json["phoneNumber"] msg = ", {}, : {}.".format(user, code) message = client.api.account.messages.create(to=user_number, from_="+1 20652 51212", body=msg) return {"status": "ok"}
次ã«ããã¥ãŒãã¬ã¹ã§FaaSãç»é²ããŸãã
kubeless function deploy add-two-factor \ --runtime python27 \ --handler two_factor.two_factor \ --from-file two_factor.py \ --trigger-http
ãã®é¢æ°ã®ã€ã³ã¹ã¿ã³ã¹ã¯ããŠãŒã¶ãŒãæ£ãããã¹ã¯ãŒããå ¥åããåŸãJavaScriptã®ã¯ã©ã€ã¢ã³ãã³ãŒãããéåæã«çæã§ããŸãã Webã€ã³ã¿ãŒãã§ãŒã¹ã¯ã³ãŒããå ¥åããããã®ããŒãžãããã«è¡šç€ºã§ãããŠãŒã¶ãŒã¯ã³ãŒããåãåããšããã«ããã®ã³ãŒããæ¢ã«ç»é²ãããŠãããã°ã€ã³ãµãŒãã¹ããŠãŒã¶ãŒã«éç¥ã§ããŸãã
ãã®ãããFaaSã¢ãããŒãã¯ããŠãŒã¶ãŒãã·ã¹ãã ã«ãã°ãªã³ãããšãã«éå§ãããåçŽãªéåæã®ã€ãã³ãæåãµãŒãã¹ã®éçºãå€§å¹ ã«ä¿é²ããŸããã
ã€ãã³ãã³ã³ãã¢
å®éãççµåã€ãã³ãã®ãã€ãã©ã€ã³ãšããŠèããã®ãç°¡åãªã¢ããªã±ãŒã·ã§ã³ãããã€ããããŸãã å€ãã®å Žåãã€ãã³ããã€ãã©ã€ã³ã¯å€ãè¯ããããŒãã£ãŒãã«äŒŒãŠããŸãã ãããã¯ãé¢é£ããã€ãã³ãã®åæã®æåã°ã©ããšããŠè¡šãããšãã§ããŸãã ã€ãã³ããã€ãã©ã€ã³ãã¿ãŒã³ã®ãã¬ãŒã ã¯ãŒã¯å ã§ã¯ãããŒãã¯é¢æ°ã«å¯Ÿå¿ããããããæ¥ç¶ããã¢ãŒã¯ã¯HTTPèŠæ±ãŸãã¯ä»ã®çš®é¡ã®ãããã¯ãŒã¯ã³ãŒã«ã«å¯Ÿå¿ããŸãã
ã³ã³ããã®èŠçŽ éã«ã¯ãååãšããŠå ±éã®ç¶æ ã¯ãããŸãããããªããžããªå ã®æ€çŽ¢ãå®è¡ãããããŒã¹ãšãªãå ±éã®ã³ã³ããã¹ããŸãã¯ä»ã®åç §ãã€ã³ããååšããå ŽåããããŸãã
ãã®ãããªãã€ãã©ã€ã³ã¢ãŒããã¯ãã£ãšãã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ã®éãã¯äœã§ããïŒ 2ã€ã®éèŠãªéãããããŸãã ãµãŒãã¹æ©èœãšç¶ç¶çã«å®è¡ããããµãŒãã¹ã®æåã®æãéèŠãªéãã¯ãã€ãã³ããã€ãã©ã€ã³ãæ¬è³ªçã«ã€ãã³ãé§ååã§ããããšã§ãã ããã©ãããããã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ã¯ãåžžã«æ©èœããäžé£ã®ãµãŒãã¹ãæå³ããŸãã ããã«ãã€ãã³ããã€ãã©ã€ã³ã¯éåæã§ãããŸããŸãªã€ãã³ãããã€ã³ãã§ããŸãã Jiraã®ã¢ããªã±ãŒã·ã§ã³æ¿èªããã€ã¯ããµãŒãã¹ã¢ããªã±ãŒã·ã§ã³ã«çµ±åããæ¹æ³ãæ³åããã®ã¯å°é£ã§ãã åæã«ãã€ãã³ããã€ãã©ã€ã³ã«ã©ã®ããã«çµ±åãããããç°¡åã«æ³åã§ããŸãã
äŸãšããŠããœãŒã¹ã€ãã³ããããŒãžã§ã³ç®¡çã·ã¹ãã ãžã®ã³ãŒãã®ããŒãã§ãããã€ãã©ã€ã³ãèããŸãã ãã®ã€ãã³ãã«ãããã³ãŒããåæ§ç¯ãããŸãã ã¢ã»ã³ããªã«ã¯æ°åãããå ŽåããããŸãããã®åŸãã€ãã³ããçæãããã¢ã»ã³ãã«ãããã¢ããªã±ãŒã·ã§ã³ã®ãã¹ãæ©èœãããªã¬ãŒãããŸãã ã¢ã»ã³ããªã®æåã«å¿ããŠããã¹ãæ©èœã¯ããŸããŸãªã¢ã¯ã·ã§ã³ãå®è¡ããŸãã ã¢ã»ã³ããªãæåããå Žåãã¢ããªã±ãŒã·ã§ã³ãäœæãããŸããã¢ããªã±ãŒã·ã§ã³ã®æ°ããããŒãžã§ã³ã䜿çšããã«ã¯ãæ¿èªãå¿ èŠã§ãã ã¢ããªã±ãŒã·ã§ã³ãéããããšã¯ãæ°ããããŒãžã§ã³ãéçšããããã®ã·ã°ãã«ãšããŠæ©èœããŸãã ã¢ã»ã³ããªã倱æããå ŽåãJiraã¯æ€åºããããšã©ãŒãèŠæ±ãããã€ãã©ã€ã³ã¯çµäºããŸãã
ã¯ãŒã¯ã·ã§ãã æ°ãããŠãŒã¶ãŒãç»é²ããããã®ãã€ãã©ã€ã³ãå®è£ ãã
æ°ãããŠãŒã¶ãŒãç»é²ããããã®äžé£ã®ã¢ã¯ã·ã§ã³ãå®è£ ããã¿ã¹ã¯ãæ€èšããŠãã ããã æ°ããã¢ã«ãŠã³ããäœæãããšããŠã§ã«ã«ã ã¡ãŒã«ã®éä¿¡ãªã©ãäžé£ã®ã¢ã¯ã·ã§ã³å šäœãåžžã«å®è¡ãããŸãã ããšãã°ã補åã®æ°ããããŒãžã§ã³ïŒã¹ãã ãšãåŒã°ããŸãïŒã«ã€ããŠã®é»åã¡ãŒã«ãã¥ãŒã¹ã¬ã¿ãŒã賌èªãããªã©ãæ¯åå®è¡ããããšã¯éããªãããã€ãã®ã¢ã¯ã·ã§ã³ããããŸãã
1ã€ã®ã¢ãããŒãã«ã¯ãæ°ããã¢ã«ãŠã³ããäœæããããã®ã¢ããªã·ãã¯ãµãŒãã¹ã®äœæãå«ãŸããŸãã ãã®ã¢ãããŒãã§ã¯ã1ã€ã®éçºããŒã ããµãŒãã¹å šäœãæ åœãããµãŒãã¹å šäœãå±éãããŸãã ããã«ãããå®éšãè¡ã£ããããŠãŒã¶ãŒãã¢ããªã±ãŒã·ã§ã³ãšããåãããããã»ã¹ãå€æŽãããããããšãé£ãããªããŸãã
è€æ°ã®FaaSãµãŒãã¹ã®ã€ãã³ããã€ãã©ã€ã³ãšããŠã®ãŠãŒã¶ãŒãã°ã€ã³ã®å®è£ ãæ€èšããŠãã ããã ãã®åé¢ã«ããããŠãŒã¶ãŒäœææ©èœã¯ãŠãŒã¶ãŒã®ãã°ã€ã³äžã«äœãèµ·ãããããããŸããã 圌女ã«ã¯2ã€ã®ãªã¹ãããããŸãã
- å¿ èŠãªã¢ã¯ã·ã§ã³ã®ãªã¹ãïŒãŠã§ã«ã«ã ã¡ãŒã«ã®éä¿¡ãªã©ïŒã
- ãªãã·ã§ã³ã®ã¢ã¯ã·ã§ã³ã®ãªã¹ãïŒãã¥ãŒã¹ã¬ã¿ãŒã®è³Œèªãªã©ïŒã
ãããã®åã¢ã¯ã·ã§ã³ãFaaSãšããŠå®è£ ãããŠãããã¢ã¯ã·ã§ã³ã®ãªã¹ãã¯HTTPã³ãŒã«ããã¯é¢æ°ã®ãªã¹ãã«ãããŸããã ãããã£ãŠããŠãŒã¶ãŒäœæé¢æ°ã®åœ¢åŒã¯æ¬¡ã®ãšããã§ãã
def create_user(context): # for key, value in required.items(): call_function(value.webhook, context.json) # # for key, value in optional.items(): if context.json.get(key, None) is not None: call_function(value.webhook, context.json)
åãã³ãã©ãŒã¯ãFaaSã®ååã«åŸã£ãŠå®è£ ããããšãã§ããŸãã
def email_user(context): # user = context.json['username'] msg = ', {}, , !".format(user) send_email(msg, contex.json['email]) def subscribe_user(context): # email = context.json['email'] subscribe_user(email)
ãã®æ¹æ³ã§å解ãããFaaSãµãŒãã¹ã¯ãã¯ããã«åçŽã«ãªããã³ãŒãã®è¡æ°ãå°ãªããªããç¹å®ã®1ã€ã®æ©èœã®å®è£ ã«çŠç¹ãåœãŠãããŸãã ãã€ã¯ããµãŒãã¹ã®ã¢ãããŒãã«ãããã³ãŒãã®èšè¿°ã¯ç°¡åã«ãªããŸããã3ã€ã®ç°ãªããã€ã¯ããµãŒãã¹ã®å±éãšç®¡çãå°é£ã«ãªãå¯èœæ§ããããŸãã ããã§ãFaaSã¢ãããŒãã¯ããã®äœ¿çšã®çµæãšããŠãã³ãŒãã®å°ããªéšåã管çããããšãéåžžã«ç°¡åã«ãªããããæ å ã®äžã§èšŒæãããŠããŸãã ã€ãã³ããã€ãã©ã€ã³ã®åœ¢åŒã§ãŠãŒã¶ãŒãäœæããããã»ã¹ãèŠèŠåãããšããã€ãã©ã€ã³å ã®æ©èœããšã®ã³ã³ããã¹ãã®å€åã远跡ããã ãã§ããŠãŒã¶ãŒãã°ã€ã³äžã«æ£ç¢ºã«äœãèµ·ããããåºãç解ã§ããŸãã
»æ¬ã®è©³çŽ°ã«ã€ããŠã¯ãåºç瀟ã®ãŠã§ããµã€ããã芧ãã ãã
» ã³ã³ãã³ã
» æç²
ãã¶ã€ããŒåãã¯ãŒãã³ã®20ïŒ å²åŒ- ãã¶ã€ã³ãã¿ãŒã³
æ¬ã®çŽçãæ¯æããããšãé»åçã®æ¬ãé»åã¡ãŒã«ã§éä¿¡ãããŸãã