Skip to content

Interservice communication #66

Description

@jirenius

Issue

The service package should support making call requests and getting resources and events from other RES services connected to NATS.

// Example of what the API might be like

// Connect client to NATS
client := res.NewClient("nats://127.0.0.1")

// Sets token used in call requests
client.SetToken(nil)

 // Get resource from another 
books, err := client.Get("library.books")

// Get resource type; res.TypeModel, res.TypeCollection
typ := books.Type()

// Returns a map[string]Value. Panics if books.Type() is not res.TypeModel
m := books.Model()

// Returns a []Value. Panics if books.Type() is not res.TypeCollection
c := books.Collection()

// Unmarshals the resource into the provided interface value
var b []Book
err := books.Unmarshal(&b)

// Subscribe to events
sub := book.Subscribe(func(r res.Resource, ev res.Event) {
    // Handle event
})

// Unsubscribe to events
sub.Unsubscribe()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions