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:
- service.yaml
- An Open API specification that describes the endpoints in this service.
- gen-proto.sh
- A script that relies on github.com/NYTimes/openapi2proto to generate a gRPC service spec with HTTP annotations from the Open API spec along with the Go/Cloud Endpoint stubs via protoc.
- service.go
- The actual kit.Service implementation.
- http_client.go
- A go-kit client for programmatically accessing the API via HTTP/JSON.
- cmd/cli/main.go
- A CLI wrapper around the gRPC client.
- .drone.yml
- An example configuration file for Drone CI using the NYTimes/drone-gke plugin for managing automated deployments to Google Container Engine.
- cloud-endpoints/service-ce-prd.yaml
- A service configuration for Google Cloud Endpoints.
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
- func NewService(db DB) (kit.Service, error)
- func RegisterReadingListServiceServer(s *grpc.Server, srv ReadingListServiceServer)
- type Client
- type DB
- type Datastore
- type GetListLimitRequest
- type Link
- type LinkRequest
- type Links
- type Message
- type PutLinkRequest
- type ReadingListServiceClient
- type ReadingListServiceServer
Constants ¶
const LinkKind = "Link"
Variables ¶
This section is empty.
Functions ¶
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
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
func (*Datastore) DeleteLink ¶
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 ¶
type Link struct {
Url string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"`
}
func (*Link) Descriptor ¶
func (*Link) ProtoMessage ¶
func (*Link) ProtoMessage()
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 (*LinkRequest) GetLink ¶
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 ¶
type Links struct {
Links []*Link `protobuf:"bytes,1,rep,name=links" json:"links,omitempty"`
}
func (*Links) Descriptor ¶
func (*Links) ProtoMessage ¶
func (*Links) ProtoMessage()
type Message ¶
type Message struct {
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
}
func (*Message) Descriptor ¶
func (*Message) GetMessage ¶
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
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) }