Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: public API #261

Closed
wants to merge 1 commit into from
Closed

Commits on Jul 31, 2023

  1. client: Export public API.

    This patch, similar in spirit to canonical#238, introduces a new public API for
    extending the Pebble client. The basic idea behind this patch is the client mixin
    struct embedded in commands' structs no longer holds an instance of the
    Pebble-specific `client.Client` struct, but instead take a `ClientGetter` interface
    that implements a `Client()` method. `ClientGetter.Client()` always returns a
    Pebble-specific `client.Client` struct.
    
    For applications that indent to extend Pebble, this means that either the Pebble
    client or a new, application-specific client can be used. In the latter case,
    the application-specific client must implement the `ClientGetter` interface so
    that a Pebble-specific `client.Client` struct can always be derived by the
    facilities consuming the `ClientGetter` interface. The easiest way to implement
    this is to embed the Pebble client:
    
        type PebbleClient = client.Client
        type MyClient struct {
            *PebbleClient
        }
    
    Since the Pebble-specific `client.Client` is embedded, and the `ClientGetter`
    interface requires `Client()` to be implemented with a pointer receiver, the
    snippet above suffices to implement a client based off the Pebble-supplied one
    without much hassle, and that provides lower-level facilities for communicating
    with the daemon, such as `DoSync()`, `DoAsync()` and `DoAsyncFull()`.
    anpep committed Jul 31, 2023
    Configuration menu
    Copy the full SHA
    37e993b View commit details
    Browse the repository at this point in the history