投稿時間:2022-10-16 17:12:44 RSSフィード2022-10-16 17:00 分まとめ(13件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita Django 複数選択フォームを動的に更新する(get_form_kwargsとMultipleChoiceField) https://qiita.com/startours777/items/f7bd0a2584dd47038275 django 2022-10-16 16:44:23
python Pythonタグが付けられた新着投稿 - Qiita Excel業務(無駄)を自動化したい part2 入力した文字をいじりたい https://qiita.com/caffeine1202/items/1a9df2ae587ab3b395dc excel 2022-10-16 16:11:08
js JavaScriptタグが付けられた新着投稿 - Qiita Amazon URLやASINをISBNに変換する https://qiita.com/ttttpzm/items/92c5210c5bcb5c4eed1d amazonurl 2022-10-16 16:14:12
Ruby Rubyタグが付けられた新着投稿 - Qiita 単体テストコード(userモデル)記述の流れ https://qiita.com/Naaa0/items/a140553703f93fc6b906 railsgrspecmodeluseruser 2022-10-16 16:40:31
Docker dockerタグが付けられた新着投稿 - Qiita PostgreSQLのサンプルスキーマのDockerfile化 https://qiita.com/ma91n/items/28a68ca8147b6a4afb77 dockerfile 2022-10-16 16:47:16
Azure Azureタグが付けられた新着投稿 - Qiita Qiita APIを使って最近のAzureに関する投稿を検索してみた。 https://qiita.com/Yuki-Tamura-85/items/d85bb201597f9fa9cb3f azure 2022-10-16 16:46:14
Ruby Railsタグが付けられた新着投稿 - Qiita 単体テストコード(userモデル)記述の流れ https://qiita.com/Naaa0/items/a140553703f93fc6b906 railsgrspecmodeluseruser 2022-10-16 16:40:31
海外TECH DEV Community Using AWS Step Functions To Implement The SAGA Pattern https://dev.to/eelayoubi/using-aws-step-functions-to-implement-the-saga-pattern-14o7 Using AWS Step Functions To Implement The SAGA Pattern IntroductionIn this post I will walk you through how to leverage AWS Step Functions to implement the SAGA Pattern Put simply the Saga pattern is a failure management pattern that provides us the means to establish semantic consistency in our distributed applications by providing compensating transactions for every transaction where you have more than one collaborating services or functions For our use case imagine we have a workflow that goes as the following The user books a hotelIf that succeeds we want to book a flightIf booking a flight succeeds we want to book a rentalIf booking a rental succeeds we consider the flow a success As you may have guessed this is the happy scenario Where everything went right shockingly However if any of the steps fails we want to undo the changes introduced by the failed step and undo all the prior steps if any What if booking the hotel step failed How do we proceed What if the booking hotel step passes but booking a flight fails We need to be able to revert the changes Example User books a hotel successfullyBooking the flight failedCancel the flight assuming the failure happened after we saved the flight record in the database Cancel the hotel recordFail the machineAWS Step functions can help us here since we can implement these functionalities as steps or tasks Step functions can orchestrate all these transitions easily Deploying The ResourcesYou will find the code repository here Please refer to this section to deploy the resources For the full list of the resources deployed check out this table DynamoDB TablesIn our example we are deploying DynamoDB tables BookHotelBookFlightBookRentalThe following is the code responsible for creating the BookHotel tablemodule book hotel ddb source modules dynamodb table name var book hotel ddb name billing mode var billing mode read capacity var read capacity write capacity var write capacity hash key var hash key hash key type var hash key type additional tags var book hotel ddb additional tags Lambda FunctionsWe will be relying on Lambda functions to implement our example BookHotelBookFlightBookRentalCancelHotelCancelFlightCancelRentalThe functions are pretty simple and straightforward BookHotel Functionexports handler async event gt const confirmation id checkin date checkout date event try await ddb putItem params promise console log Success catch error console log Error error throw new Error Unexpected Error if confirmation id startsWith throw new BookHotelError Expected Error return confirmation id checkin date checkout date For the full code please checkout the index js fileAs you can see the function expects an input of the following format confirmation idcheckin datecheckout dateThe function will create an item in the BookHotel table And it will return the input as an output To trigger an error you can create a confirmation id that starts with this will throw a custom error that the step function will catch CancelHotel Functionconst AWS require aws sdk const ddb new AWS DynamoDB apiVersion const TABLE NAME process env TABLE NAMEexports handler async event gt var params TableName TABLE NAME Key id S event confirmation id try await ddb deleteItem params promise console log Success return statusCode body Cancel Hotel uccess catch error console log Error error throw new Error ServerError This function simply deletes the item that was created by the BookHotel function using the confirmation id as a key We could have checked if the item was created But to keep it simple and I am assuming that the failure of the Booking functions always happen after the records were created in the tables NOTE The same logic goes for all the other Book and Cancel functions Reservation Step Function Step Functionmodule step function source terraform aws modules step functions aws name Reservation definition templatefile path module state machine reservation asl json BOOK HOTEL FUNCTION ARN module book hotel lambda function arn CANCEL HOTEL FUNCTION ARN module cancel hotel lambda function arn BOOK FLIGHT FUNCTION ARN module book flight lambda function arn CANCEL FLIGHT FUNCTION ARN module cancel flight lambda function arn BOOK RENTAL LAMBDA ARN module book rental lambda function arn CANCEL RENTAL LAMBDA ARN module cancel rental lambda function arn service integrations lambda lambda module book hotel lambda function arn module book flight lambda function arn module book rental lambda function arn module cancel hotel lambda function arn module cancel flight lambda function arn module cancel rental lambda function arn type STANDARD This is the code that creates the step function I am relying on a terraform module to create it This piece of code will create a step function with the reservation asl json file as a definition And in the service integrations we are giving the step function the permission to invoke the lambda functions since these functions are all part of the step function workflow Below is the full diagram for the step funtion The reservation asl json is relying on the Amazon State language If you open the file you will notice on the second line the StartAt BookHotel This tells the step functions to start at the BookHotel State Happy Scenario BookHotel Type Task Resource BOOK HOTEL FUNCTION ARN TimeoutSeconds Retry ErrorEquals States Timeout Lambda ServiceException Lambda AWSLambdaException Lambda SdkClientException IntervalSeconds MaxAttempts BackoffRate Catch ErrorEquals BookHotelError ResultPath error info Next CancelHotel Next BookFlight The BookHotel state is a Task With a Resource that will be resolved to the BookHotel Lambda Function via terraform As you might have noticed I am using a retry block Where the step function will retry executing the BookHotel functions up to times after the first attempt in case of an error that is equal to any of the following errors States Timeout Lambda ServiceException Lambda AWSLambdaException Lambda SdkClientException You can ignore the Catch block for now we will get back to it in the unhappy scenario section After the BookHotel task is done the step function will transition to the BookFlight as specified in the Next field BookFlight Type Task Resource BOOK FLIGHT FUNCTION ARN TimeoutSeconds Retry ErrorEquals States Timeout Lambda ServiceException Lambda AWSLambdaException Lambda SdkClientException IntervalSeconds MaxAttempts BackoffRate Catch ErrorEquals BookFlightError ResultPath error info Next CancelFlight Next BookRental The BookFlight state follows the same pattern As we retry invoking the BookFlight function if we face any of the errors specified in the Retry block If no error is thrown the step function will transition to the BookRental state BookRental Type Task Resource BOOK RENTAL LAMBDA ARN TimeoutSeconds Retry ErrorEquals States Timeout Lambda ServiceException Lambda AWSLambdaException Lambda SdkClientException IntervalSeconds MaxAttempts BackoffRate Catch ErrorEquals BookRentalError ResultPath error info Next CancelRental Next ReservationSucceeded The BookRental state follows the same pattern Again we retry invoking the BookRental function if we face any of the errors specified in the Retry block If no error is thrown the step function will transition to the ReservationSucceeded state ReservationSucceeded Type Succeed The ReservationSucceeded is a state with Succeed type In this case it terminates the state machine successfully Unhappy Scenarios Oh no BookHotel failedAs you recall in the BookHotel state I included a Catch block In the BookHotel function if the confirmation id starts with a custom error of BookHotelError type will be thrown This Catch block will catch it and will use the state mentioned in the Next field which is the CancelHotel in this case CancelHotel Type Task Resource CANCEL HOTEL FUNCTION ARN ResultPath output cancel hotel TimeoutSeconds Retry ErrorEquals States Timeout Lambda ServiceException Lambda AWSLambdaException Lambda SdkClientException IntervalSeconds MaxAttempts BackoffRate Next ReservationFailed The CancelHotel is a Task as well and has a retry block to retry invoking the function in case of an unexpected error The Next field instructs the step function to transition to the ReservationFailed state ReservationFailed Type Fail The ReservationFailed state is a Fail type it will terminate the machine and mark it as Failed BookFlight is failingWe can instruct the BookFlight lambda function to throw an error by passing a confirmation id that starts with The BookFlight step function task has a Catch block that will catch the BookFlightError and instruct the step function to transition to the CancelFlight state CancelFlight Type Task Resource CANCEL FLIGHT FUNCTION ARN ResultPath output cancel flight TimeoutSeconds Retry ErrorEquals States Timeout Lambda ServiceException Lambda AWSLambdaException Lambda SdkClientException IntervalSeconds MaxAttempts BackoffRate Next CancelHotel Similar to the CancelHotel the CancelFlight state will trigger the CancelFlight lambda function to undo the changes Then it will instruct the step function to go to the next step CancelHotel And we saw earlier that the CancelHotel will undo the changes introduced by the BookHotel and will then call the ReservationFailed to terminate the machine BookRental is failingThe BookRental lambda function will throw the ErrorBookRental error if the confirmation id starts with This error will be caught by the Catch block in the BookRental task And will instruct the step function to go to the CancelRental state CancelRental Type Task Resource CANCEL RENTAL LAMBDA ARN ResultPath output cancel rental TimeoutSeconds Retry ErrorEquals States Timeout Lambda ServiceException Lambda AWSLambdaException Lambda SdkClientException IntervalSeconds MaxAttempts BackoffRate Next CancelFlight Similar to the CancelFlight the CancelRental state will trigger the CancelRental lambda function to undo the changes Then it will instruct the step function to go to the next step CancelFlight After cancelling the flight the CancelFlight has a Next field that instructs the step function to transition to the CancelHotel state which will undo the changes and call the ReservationFailed state to terminate the machine ConclusionIn this post we saw how we can leverage AWS Step Functions to orchestrate and implement a fail management strategy to establish semantic consistency in our distributed reservation application I hope you found this article beneficial Thank you for reading Additional Resources 2022-10-16 07:27:01
海外TECH DEV Community 6 Cool Things Boring Old HTML Can Do 🤯 https://dev.to/ruppysuppy/6-cool-things-boring-old-html-can-do-3160 Cool Things Boring Old HTML Can Do Ever wondered does HTML always have to be boring No way Here are cool things you can do with HTML that you might not have known about Preload amp cache assets Wondering how to preload and cache assets It just requires a single line of code amp you are done lt link rel preload href as image gt Add Custom Link Previews for the page ️Mystified by how link previews are generated All it needs are the meta tags lt meta property og title content Page title gt lt meta property og description content Page description gt lt meta property og image content gt The meta tags shown above use Open Graph Protocol you can use any meta tag generator to generate the tags for all the other platforms eg Twitter Cards Redirect to another link ️Redirecting users to other links used commonly after payment confirmation is just a single line of code away lt meta http equiv refresh content url gt The above code will redirect the user to Google after seconds Make a call or mail Need a link to make a call or mail a tag to the rescue lt a href tel gt Call lt a gt lt a href mailto user emaul com gt Mail lt a gt Add a Color Picker Want to add a color picker to your website One line is all you need no fancy libraries or even JavaScript required lt input type color gt Editable Content ️You can make any content editable by just adding the contenteditable attribute to the element lt p contenteditable true gt This is an editable paragraph lt p gt When used with proper styling it can even be used to create a WYSIWYG editor NOTE Beware of the security issues that might arise when using this attribute so steer clear of it if you are unaware of the implications That s all folks Thanks for readingNeed a Top Rated Front End Development Freelancer to chop away your development woes Contact me on UpworkWant to see what I am working on Check out my Personal Website and GitHubWant to connect Reach out to me on LinkedInI am a Digital Nomad and occasionally travel Follow me on Instagram to check out what I am up to Follow my blogs for bi weekly new tidbits on DevFAQThese are a few commonly asked questions I get So I hope this FAQ section solves your issues I am a beginner how should I learn Front End Web Dev Look into the following articles Front End Development RoadmapFront End Project IdeasWould you mentor me Sorry I am already under a lot of workload and would not have the time to mentor anyone 2022-10-16 07:17:55
ニュース BBC News - Home Jeremy Hunt to join Liz Truss at Chequers for talks on economic plans https://www.bbc.co.uk/news/uk-politics-63274313?at_medium=RSS&at_campaign=KARANGA chancellor 2022-10-16 07:37:12
ニュース BBC News - Home T20 World Cup: Namibia shock Sri Lanka in opening game https://www.bbc.co.uk/sport/cricket/63274707?at_medium=RSS&at_campaign=KARANGA fashion 2022-10-16 07:40:53
北海道 北海道新聞 黄色の「山里の貴婦人」満開 和歌山県すさみ町 https://www.hokkaido-np.co.jp/article/746078/ 和歌山県すさみ町 2022-10-16 16:01:27
海外TECH reddit Worst customer service you've seen in Japan? https://www.reddit.com/r/japanlife/comments/y5adl9/worst_customer_service_youve_seen_in_japan/ Worst customer service you x ve seen in Japan Japan s customer service is generally pretty good so I was pretty shocked when I visited a cafe today and had the worst service I ve experienced in any country A Japanese acquaintance and I went to a cafe run by a guy who s apparently some world champion latte art competitor and has overseas work experience according to the cafe s website After we were served my acquaintance asked for some milk to put in his coffee The owner s ego apparently couldn t handle this and demanded that my acquaintance try the coffee as it had been made So my acquaintance did and still wanted the milk The owner reluctantly brought the milk and started berating him quot There are plenty of family restaurants around why did you even come here quot I mean I get it you take pride in your coffee but we paid for it leave us alone man I should mention that I am Asian and pass for a Japanese person As the owner returns to the kitchen he calls my acquaintance quot fucking stupid quot in English loud enough for the whole store to hear undoubtedly assuming that my acquaintance and I are Japanese and won t understand him As we left my acquaintance still had the grace to sayどうも、ごちそうさまでしたand the owner completely ignored us lol Welp never going to that shithole again Share your stories submitted by u Yoshikki to r japanlife link comments 2022-10-16 07:17:48

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)