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

Implement the localhost Adapter and its REST endpoints #10

Open
lance opened this issue Aug 31, 2020 · 0 comments
Open

Implement the localhost Adapter and its REST endpoints #10

lance opened this issue Aug 31, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@lance
Copy link
Member

lance commented Aug 31, 2020

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)
    }
@lance lance added the enhancement New feature or request label Aug 31, 2020
@zroubalik zroubalik self-assigned this Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants