Chapter 10: Polymorphic storage
June 24, 2025 ยท View on GitHub
This chapter explains using implicit interfaces to decouple storage from its consumers and highlights consumer-defined interfaces.
Topics covered
- Interacting with SQL databases
- Understanding the driver pattern
- Integration-testing external services
- Leveraging consumer-driven interface approach
Sections
Section 1: Interacting with SQL databases
- Listing 10.1: Registering the SQLite driver
- Listing 10.2: Dialing the database
- Listing 10.3: Defining the SQL schema
- Listing 10.4: Applying the schema
Section 2: Database-backed service
- Listing 10.5: Shortening links
- Listing 10.6: Adding a test database helper
- Listing 10.7: Testing
Shortener.Shorten - Listing 10.8: Detecting constraint errors
- Listing 10.9: Detecting duplicate keys
- Listing 10.10: Resolving links