Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
160 views
74 slides
May 28, 2024
Slide 1 of 74
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
About This Presentation
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn...
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Size: 11.29 MB
Language: en
Added: May 28, 2024
Slides: 74 pages
Slide Content
Generating a custom Ruby SDK for your web service or Rails API Matt Muller SDE @ AWS 1
Who am I? Example Use Case and Service Smithy Overview Using Smithy to model and generate an SDK Deep dive into SDK usage and components Final thoughts Agenda 2
Software Engineer @ AWS (AWS SDK for Ruby) Ruby advocate First time presenting (at a developer conference) First time in Japan 3 Who am I?
Let’s get started… 4
Use Case Scenario 5
Example Application 6 “High Score Service”
Create Rails API 7
Scaffolding 8
Migrate database 9
Run server 10
Call our API 11
Generating an SDK for your API in Smithy 12
What is Smithy? Smithy is a language for defining services and SDKs. 13
Features of Smithy 14 Protocol-agnostic Designed to evolve API governance Resource based Works for any programming languages Describe services running in any environment Works with any transport format Extended through traits Extensible meta-model Avoid breaking changes Customizable API standards Validation rules across all APIs Models are defined by resources and operations Rich information for model transformations
Installing smithy-cli 15
Modeling the High Score service 16
Writing the model 17 model/high-score- service.smithy
Writing the model (continued) 18 Map to CRUD controller actions!
Writing the model (continued) 19 high_scores_controller.rb in myapp
Writing the model (continued) 20
Writing the model (continued) 21 high_scores_controller.rb in myapp
Writing the model (continued) 22 seeds.rb in myapp
Writing smithy- build.json 23
Generating the SDK 24
What’s included? 25
Using the SDK 26
Using the SDK (continued) 27
Using the SDK (continued) 28
How does it work? 29
Benefits of a Smithy Ruby SDK Easy to use Rich features Highly extensible at runtime Code generated Bring your own protocol and integrations 30
Public Features 31
Client API entry point Accepts configuration Calls operations 32
Client (continued) 33
Config Configure options and components for your SDK Per-operation override of config 34
Config (continued) 35
Types Data containers for input and output 36
Types (continued) 37
Logging Standard Ruby Logger Debug SDK internals or wire logging 38
Logging (continued) 39
Errors Standard Ruby Exceptions Follows a hierarchy Modeled or unmodeled error handling 40
Errors (continued) 41
Errors (continued) 42 models/high-score- service.smithy models/ high_score.rb in myapp
Errors (continued) 43
Errors (continued) 44
HTTP Client Bring your own HTTP Client Includes a Net::HTTP default 45
Stubbing Mock responses for testing Does not use the network 51
Stubbing (continued) 52
Interceptors Lifecycle hooks into the SDK Modify input, output, request, or response 53
Interceptors (continued) 54
Interceptors (continued) 55
Plugins Distributable code that modifies config 56
Plugins (continued) 57
Waiters ”waits” (blocks) until some condition Uses polling on an interval basis 58
Waiters (continued) 59
Waiters (continued) 60
Paginators Paginated service calls Enumerators for both pages and items 61
Paginators (continued) 62
Paginators (continued) 63
Other features Modeled auth (Bearer, SigV4, HTTP basic/digest) Modeled and dynamic endpoint resolution DNS resolving hooks in the HTTP client Connection pooling Your next great idea 64
Diving deeper into internals … 65
Builders 66
Parsers 67
Validators 68
Params 69
Stubs 70
Middleware 71
Middleware (continued) 72
What do you think? Experimental Feedback welcomed! Backbone of a future version of AWS SDK for Ruby 73
Matt Muller GitHub: mullermp No other socials 74 Smithy Ruby https://github.com/smithy-lang/smithy-ruby Today’s Demo https://github.com/mullermp/rubykaigi2024