readinglist

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

README

The 'Reading List' Example

This example implements a clone of NYT's 'saved articles API' that allows users to save, delete and retrieve nytimes.com article URLs.

This service utilizes Google Cloud Datastore and is set up to be built and published to Google Container Registry, deployed to Google Container Engine and monitored by Google Cloud Tracing.

Instead of utilizing NYT's auth, this example leans on Google OAuth and Google Cloud Endpoints for user identity.

To run locally, have the latest version of gcloud installed and execute the ./run_local.sh script to start up the Datastore emulator and the reading list server.

A few highlights of this service worth calling out:

This example mirrors an example in gizmo's sibling server for Google App Engine, marvin.

Documentation

Overview

Package readinglist is a generated protocol buffer package.

It is generated from these files:

service.proto

It has these top-level messages:

PutLinkRequest
GetListLimitRequest
Link
LinkRequest
Links
Message

Index

Constants

View Source
const LinkKind = "Link"

Variables

This section is empty.

Functions

func NewService

func NewService(db DB) (kit.Service, error)

func RegisterReadingListServiceServer

func RegisterReadingListServiceServer(s *grpc.Server, srv ReadingListServiceServer)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(host string, l log.Logger, opts ...httptransport.ClientOption) *Client
func (c Client) GetLinks(ctx context.Context, limit int) (*Links, error)
func (c Client) PutLink(ctx context.Context, url string, delete bool) (*Message, error)

type DB

type DB interface {
	GetLinks(ctx context.Context, userID string, limit int) ([]string, error)
	PutLink(ctx context.Context, userID string, url string) error
	DeleteLink(ctx context.Context, userID string, url string) error
}

type Datastore

type Datastore struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB() (*Datastore, error)
func (d *Datastore) DeleteLink(ctx context.Context, userID string, url string) error
func (d *Datastore) GetLinks(ctx context.Context, userID string, limit int) ([]string, error)
func (d *Datastore) PutLink(ctx context.Context, userID string, url string) error

type GetListLimitRequest

type GetListLimitRequest struct {
	// The limit of links to fetch
	Limit int32 `protobuf:"varint,1,opt,name=limit" json:"limit,omitempty"`
}

func (*GetListLimitRequest) Descriptor

func (*GetListLimitRequest) Descriptor() ([]byte, []int)

func (*GetListLimitRequest) GetLimit

func (m *GetListLimitRequest) GetLimit() int32

func (*GetListLimitRequest) ProtoMessage

func (*GetListLimitRequest) ProtoMessage()

func (*GetListLimitRequest) Reset

func (m *GetListLimitRequest) Reset()

func (*GetListLimitRequest) String

func (m *GetListLimitRequest) String() string
type Link struct {
	Url string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"`
}

func (*Link) Descriptor

func (*Link) Descriptor() ([]byte, []int)

func (*Link) GetUrl

func (m *Link) GetUrl() string

func (*Link) ProtoMessage

func (*Link) ProtoMessage()

func (*Link) Reset

func (m *Link) Reset()

func (*Link) String

func (m *Link) String() string

type LinkRequest

type LinkRequest struct {
	// True to remove this link from the user's list.
	Delete bool  `protobuf:"varint,1,opt,name=delete" json:"delete,omitempty"`
	Link   *Link `protobuf:"bytes,2,opt,name=link" json:"link,omitempty"`
}

func (*LinkRequest) Descriptor

func (*LinkRequest) Descriptor() ([]byte, []int)

func (*LinkRequest) GetDelete

func (m *LinkRequest) GetDelete() bool
func (m *LinkRequest) GetLink() *Link

func (*LinkRequest) ProtoMessage

func (*LinkRequest) ProtoMessage()

func (*LinkRequest) Reset

func (m *LinkRequest) Reset()

func (*LinkRequest) String

func (m *LinkRequest) String() string
type Links struct {
	Links []*Link `protobuf:"bytes,1,rep,name=links" json:"links,omitempty"`
}

func (*Links) Descriptor

func (*Links) Descriptor() ([]byte, []int)
func (m *Links) GetLinks() []*Link

func (*Links) ProtoMessage

func (*Links) ProtoMessage()

func (*Links) Reset

func (m *Links) Reset()

func (*Links) String

func (m *Links) String() string

type Message

type Message struct {
	Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
}

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetMessage

func (m *Message) GetMessage() string

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

type PutLinkRequest

type PutLinkRequest struct {
	// The Link to save
	Request *LinkRequest `protobuf:"bytes,1,opt,name=request" json:"request,omitempty"`
}

func (*PutLinkRequest) Descriptor

func (*PutLinkRequest) Descriptor() ([]byte, []int)

func (*PutLinkRequest) GetRequest

func (m *PutLinkRequest) GetRequest() *LinkRequest

func (*PutLinkRequest) ProtoMessage

func (*PutLinkRequest) ProtoMessage()

func (*PutLinkRequest) Reset

func (m *PutLinkRequest) Reset()

func (*PutLinkRequest) String

func (m *PutLinkRequest) String() string

type ReadingListServiceClient

type ReadingListServiceClient interface {
	// Save a link via JSON or Protobuf
	PutLink(ctx context.Context, in *PutLinkRequest, opts ...grpc.CallOption) (*Message, error)
	// Get your links via JSON or Protobuf
	GetListLimit(ctx context.Context, in *GetListLimitRequest, opts ...grpc.CallOption) (*Links, error)
}

func NewReadingListServiceClient

func NewReadingListServiceClient(cc *grpc.ClientConn) ReadingListServiceClient

type ReadingListServiceServer

type ReadingListServiceServer interface {
	// Save a link via JSON or Protobuf
	PutLink(context.Context, *PutLinkRequest) (*Message, error)
	// Get your links via JSON or Protobuf
	GetListLimit(context.Context, *GetListLimitRequest) (*Links, error)
}

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL