Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo
Cloud Native Go: Building Web Applications and Microservices for the Cloud with Go and React

Book Description

The Complete Guide to Building Cloud-Based Services

Cloud Native Go shows developers how to build massive cloud applications that meet the insatiable demands of today’s customers, and will dynamically scale to handle virtually any volume of data, traffic, or users.
 
Kevin Hoffman and Dan Nemeth describe the modern cloud-native application in detail, illuminating factors, disciplines, and habits associated with rapid, reliable cloud-native development. They also introduce Go, a “simply elegant” high-performance language that is especially well-suited for cloud development.

You’ll walk through creating microservices in Go, adding front-end web components using ReactJS and Flux, and mastering advanced Go-based cloud-native techniques. Hoffman and Nemeth show how to build a continuous delivery pipeline with tools like Wercker, Docker, and Dockerhub; automatically push apps to leading platforms; and systematically monitor app performance in production.

  • Learn “The Way of the Cloud”: why developing good cloud software is fundamentally about mindset and discipline

  • Discover why Go is ideal for cloud-native microservices development

  • Plan cloud apps that support continuous delivery and deployment

  • Design service ecosystems, and then build them in a test-first manner

  • Push work-in-progress to a cloud

  • Use Event Sourcing and CQRS patterns to react and respond to enormous volume and throughput

  • Secure cloud-based web applications: do’s, don’ts, and options

  • Create reactive applications in the cloud with third-party messaging providers

  • Build massive-scale, cloud-friendly GUIs with React and Flux

  • Monitor dynamic scaling, failover, and fault tolerance in the cloud

  • Table of Contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Dedication Page
    5. Contents at a Glance
    6. Contents
    7. Preface
    8. About the Authors
    9. Acknowledgments
    10. 1. The Way of the Cloud
      1. The Virtues of the Way of the Cloud
        1. Favor Simplicity
        2. Test First, Test Everything
        3. Release Early, Release Often
        4. Automate Everything
        5. Build Service Ecosystems
      2. Why Use Go?
        1. Simplicity
        2. Open Source
        3. Easy Automation and IDE Freedom
      3. Summary
    11. 2. Getting Started
      1. The Right Tools for the Job
      2. Setting Up Git
        1. Installing Homebrew
        2. Installing the Git Client
        3. Installing Mercurial and Bazaar
        4. Creating a GitHub Account
      3. Setting Up Go
        1. Configuring your Go Workspace
      4. Testing Your Environment
      5. Summary
    12. 3. Go Primer
      1. Building Hello Cloud
      2. Using Basic Functions
      3. Working with Structs
      4. Introducing Go Interfaces
      5. Adding Methods to Structs
        1. Exploiting Dynamic Typing in Go with Interfaces
      6. Working with Third-Party Packages
      7. Creating Your Own Packages
        1. Exporting Functions and Data
        2. Creating a Package
      8. Summary
    13. 4. Delivering Continuously
      1. Introducing Docker
        1. Why use Docker?
        2. Installing Docker
        3. Running Docker Images
      2. Continuous Integration with Wercker
        1. Continuous Integration Best Practices
        2. Why use Wercker?
        3. Creating a Wercker Application
        4. Installing the Wercker CLI
        5. Creating a Wercker Configuration File
        6. Running a Wercker Build
        7. Deploying to DockerHub
      3. Reader Exercise: Create a Full Development Pipeline
        1. Advanced Challenge: Integrate Third-Party Library
      4. Summary
    14. 5. Building Microservices in Go
      1. Designing Services API First
        1. Designing the Matches API
        2. Creating an API Blueprint
        3. Testing and Publishing Documentation with Apiary
      2. Scaffolding a Microservice
      3. Building Services Test First
        1. Creating a First, Failing Test
        2. Testing the Location Header
        3. Epic Montage—Test Iterations
      4. Deploying and Running in the Cloud
        1. Creating a PWS Account
        2. Setting up PCF Dev
        3. Pushing to Cloud Foundry
      5. Summary
    15. 6. Using Backing Services
      1. Designing Service Ecosystems
      2. Building Dependent Services Test-First
        1. Creating the Fulfillment Service
        2. Creating the Catalog Service
      3. Sharing Structured Data Among Services
        1. Client Imports Server Package
        2. Client Duplicates Server Structure
        3. Client And Server Import Shared Package
      4. Using Service Bindings to Externalize URLs and Metadata
      5. Discovering Services
        1. Dynamic Service Discovery
        2. Service Discovery with Netflix’s Eureka
      6. Reader Exercise
        1. Bonus Activity
      7. Summary
    16. 7. Creating a Data Service
      1. Creating a MongoDB Match Repository
        1. Why MongoDB?
        2. Updating the Repository Pattern
        3. Communicating with MongoDB in Go
        4. Writing a MongoDB Repository Test-First
      2. Integration Testing a Mongo-Backed Service
        1. Integrating with a Transient MongoDB Database
        2. Writing an Integration Test
      3. Running in the Cloud
        1. Configuring a Backing Service
      4. Summary
    17. 8. Event Sourcing and CQRS
      1. Reality is Event Sourced
        1. Idempotent
        2. Isolated
        3. Testable
        4. Replayable and Recoverable
        5. Big Data
      2. Embracing Eventual Consistency
      3. Introducing Command Query Responsibility Segregation
      4. Event Sourcing Use Cases
        1. Weather Monitoring
        2. Connected Cars
        3. Social Media Feed Processing
      5. Code Sample: Managing a Drone Army
      6. Creating a Command Handler Service
        1. Introduction to RabbitMQ
        2. Building the Command Handler Service
      7. Building the Event Processor
        1. Integration Testing the Event Processor
      8. Creating the Query Handler Service
      9. Summary
    18. 9. Building a Web Application with Go
      1. Serving Static Files and Assets
      2. Supporting JavaScript Clients
      3. Using Server-Side Templates
      4. Processing Forms
      5. Working with Cookies and Session State
        1. Writing Cookies
        2. Reading Cookies
      6. Build and Deploy with Wercker
      7. Summary
    19. 10. Security in the Cloud
      1. Securing a Web Application
        1. Web Application Security Options
        2. Setting up an Auth0 Account
        3. Building an OAuth-Secured Web App
        4. Running the SecureWeb Application
      2. Securing Microservices
        1. Overview of the Client Credentials Pattern
        2. Securing a Microservice with Client Credentials
        3. A Note on SSL
      3. A Word on Privacy and Data Security
        1. Hackers Can’t Get What You Don’t Have
      4. Reader Exercise
      5. Summary
    20. 11. Working with WebSockets
      1. Demystifying WebSockets
        1. How WebSockets Work
        2. WebSockets vs. Server-Sent Events
        3. Designing a WebSocket Server
      2. On WebSockets and Cloud Nativity
      3. Building a WebSocket App with a Messaging Provider
        1. A Note on JavaScript Frameworks
        2. Running the WebSockets Sample
      4. Summary
    21. 12. Building Web Views with React
      1. JavaScript State of the Union
      2. Why React?
        1. The Virtual DOM
        2. Component Composition
        3. Reactive Data Flow
        4. Narrow Focus
        5. Ease* of Use
      3. Anatomy of a React Application
        1. The package.json File
        2. Webpack.config.js
        3. The .babelrc File
        4. Understanding JSX and Webpack
        5. React Components
      4. Building a Simple React Application
        1. What We Didn’t Like
      5. Testing React Applications
      6. Further Reading
        1. React Websites
        2. React Books
        3. Other Materials
      7. Summary
    22. 13. Creating UIs that Scale with Flux
      1. Introducing Flux
        1. Dispatcher
        2. Store
        3. View
        4. Action
        5. Source
        6. Complexity in Flux
      2. Building a Flux Application
      3. Summary
    23. 14. Creating a Full Application—World of FluxCraft
      1. Introducing World of FluxCraft
      2. Architectural Overview
        1. Independent Scaling, Versioning, and Deployment
        2. Databases are not the Integration Tier
        3. One-Way Immutable Data Flow
      3. The Flux GUI
        1. The Go UI Host Service
        2. Sample Player Move Sequence
      4. Processing Commands
      5. Processing Events
      6. Maintaining Reality
      7. Map Management
      8. Automating Acceptance Tests
      9. Summary
    24. 15. Conclusion
      1. What we Learned
        1. Go Isn’t Just a Niche Language
        2. How Micro Should a Microservice Be?
        3. Continuous Delivery and Deployment
        4. Test Everything
        5. Release Early, Release Often
        6. Event Sourcing, CQRS, and More Acronyms
      2. Next Steps
    25. A. Troubleshooting Cloud Applications
      1. Working with Log Streams
      2. Monitoring Health and Performance
        1. Application Performance Monitoring (APM) Tools
        2. Monitoring Your App via the Platform
      3. Debugging Applications in the Cloud
    26. Index
    27. Code Snippets