liveBook · Manning

Client library

As explained in Platform Engineering on Kubernetes

A client library is a software library that provides application code with programmatic access to an external service or system.

A client library gives application code programmatic access to an external service or system. Cloud-provider SDKs package calls to service APIs as dependencies in a programming language, avoiding manually crafted requests. That convenience can couple application code to a provider: upgrading the SDK may require an application release, and an SDK may conflict with a framework or lack support for a language. section 1.1.3

Choose the dependency according to what it couples the application to:

  • A Dapr SDK helps code call Dapr APIs without constructing HTTP or gRPC requests. It is optional, and its dependency is not tied to the infrastructure component behind those APIs. section 7.3.3
  • A Dagger SDK lets developers define pipelines in code for the Dagger engine to run locally or remotely; the pipelines do not require Kubernetes CRDs or YAML. section 3.5.4
  • A direct database client can meet an edge case that platform capability APIs cannot. The service then depends on that database and a particular client version. section 7.2.1

State access with or without an SDK

An application can add a Dapr SDK dependency to call a statestore, or send HTTP requests to the Dapr state endpoint itself. The SDK saves request-writing work; the API remains available when the helper is unsuitable. section 7.3.3

Listing 3.11 Go application defining tasks using Dagger
func main() {
  var err error
  ctx := context.Background()
  if len(os.Args) < 2 {
    ...)
  }
  client := getDaggerClient(ctx)
  defer client.Close()
  switch os.Args[1] {
    case "build":
      if len(os.Args) < 3 {
        panic(...)
      }
      _, err = buildService(ctx, client, os.Args[2])
      
    case "test":
      err = testService(ctx, client, os.Args[2])
    case "publish":
      pv, err := buildService(ctx, client, os.Args[2])
     
      err = publishService(ctx, client, os.Args[2], pv, os.Args[3])
    case "all":
      pv, err := buildService(ctx, client, os.Args[2])
      err = testService(ctx, client, os.Args[2])
      err = publishService(ctx, client, os.Args[2], pv, os.Args[3])
   default:
     log.Fatalln("invalid command specified")
}

A Go pipeline entry point obtains a Dagger client, passes it to build, test, and publish tasks, then closes it. section 3.5.4

How Platform Engineering on Kubernetes covers it

How deep it goes
Explains dependency and coupling trade-offs, then shows a Go client in pipeline code; stops short of implementing an SDK.
Examples
Uses Dapr statestore requests, a Go Dagger pipeline client, and a service that bypasses platform APIs through a database client.
What it assumes
Assumes familiarity with application dependencies and programming-language tooling; illustrates direct API access with curl rather than teaching HTTP from zero.
What you can do after
Evaluate/understand when an SDK saves request-writing effort and when its provider or database dependency creates unacceptable coupling.
How it connects
Connects client libraries to service APIs, HTTP and gRPC requests, platform capability APIs, and database dependencies.

Also explained in

Compare how 5 books explain client library →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Platform Engineering on Kubernetes. The section links point to the parts of the book it draws on.