Skip to content

Implement the localhost Adapter and its REST endpoints #10

Open
@lance

Description

Description

The Adapter interface provides concrete realizations of an EventManager and SubscriptionManager for a specific platform - in this case, localhost. A function can query the grid REST API to list, create and delete event sources and types. Note that this aligns quite well with the proposed CNCF CloudSubscriptions Discovery API. A function may also query the grid API to list, create and delete event subscriptions. This aligns well with the proposed CNCF CloudEvents Subscriptions API. We should track and be involved with these CNCF projects as we move forward with grid implementation, and consider making our exposed API align with these specifications.

The first Adapter implementation will be for localhost. We will need to provide endpoints for the REST API, and implement the EventManager and SubscriptionManager interfaces for localhost. The usage scenario is when a developer is creating, testing and changing a function locally. The Adapter should be capable of exposing mock services and events. Further iterations of the Adapter may also consider providing configuration options, such that it can expose actual, running services. For example, a localhost Adapter could be configured to expose events and subscriptions from a local or remote Kafka service.

Endpoints

  • Provide HTTP handlers for creating, listing and deleting event subscriptions at the endpoint /v1/subscriptions.
  • Provide HTTP handlers for creating, listing, (querying?) and deleting event sources and their types at /v1/events. (Note, I think we should consider changing this to /v1/services to align better with CNCF)

Interfaces

  • Implement the localhost Adapter interface:

    grid/grid.go

    Lines 25 to 29 in f6f3f6c

    type Adapter interface {
    Instances() (int, error)
    SubscriptionManager() SubscriptionManager
    EventManager() EventManager
    }
  • Implement the localhost EventManager, responsible for exposing available services / events:

    grid/grid.go

    Lines 42 to 49 in f6f3f6c

    type EventManager interface {
    // Create an event registration
    Create(string) error
    // Delete an event registration (must have been created by this service).
    Delete(string) error
    // List all available events
    List() ([]string, error)
    }
    (note that the comment in this code is not really correct - the event manager is responsible for exposing event sources/services - not registrations. That's for what's below.
  • Implement the localhost SubscriptionManager responsible for exposing subscriptions to events:

    grid/grid.go

    Lines 32 to 39 in f6f3f6c

    type SubscriptionManager interface {
    // Create a new subscription
    Create(string) error
    // Delete a subscription
    Delete(string) error
    // List all active subscriptions
    List() ([]string, error)
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions