mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
App API (#291)
* app deployment * add source to deployment * support without https prefix * add image * minor comment * fix deploy * further fixes * fix the error output * add account name * set limits * fix error handling * fix app handler * fix unmarshalling * remove http2 * set status * fix bug * . * add ability to specify branch * . * . * add better error handling * add app limit * add function limit * update app readme * log status error * update app to use the store * remove double e limit * switch to created/updated * update app handler * 5 bucks * 10 bucks * unique deployments * fix the sid * unique name handling * allow running where reservation expired * check for reservations * update readme * fix update check * update proto comment * add resolve endpoint * ship with domain * fix url * create unprivileged service account * add service account to update * . * . * update comment * . * update public api json
This commit is contained in:
1265
app/proto/app.pb.go
1265
app/proto/app.pb.go
File diff suppressed because it is too large
Load Diff
@@ -43,7 +43,13 @@ func NewAppEndpoints() []*api.Endpoint {
|
||||
|
||||
type AppService interface {
|
||||
Reserve(ctx context.Context, in *ReserveRequest, opts ...client.CallOption) (*ReserveResponse, error)
|
||||
Vote(ctx context.Context, in *VoteRequest, opts ...client.CallOption) (*VoteResponse, error)
|
||||
Regions(ctx context.Context, in *RegionsRequest, opts ...client.CallOption) (*RegionsResponse, error)
|
||||
Run(ctx context.Context, in *RunRequest, opts ...client.CallOption) (*RunResponse, error)
|
||||
Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error)
|
||||
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
|
||||
Status(ctx context.Context, in *StatusRequest, opts ...client.CallOption) (*StatusResponse, error)
|
||||
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
|
||||
Resolve(ctx context.Context, in *ResolveRequest, opts ...client.CallOption) (*ResolveResponse, error)
|
||||
}
|
||||
|
||||
type appService struct {
|
||||
@@ -68,9 +74,69 @@ func (c *appService) Reserve(ctx context.Context, in *ReserveRequest, opts ...cl
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appService) Vote(ctx context.Context, in *VoteRequest, opts ...client.CallOption) (*VoteResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "App.Vote", in)
|
||||
out := new(VoteResponse)
|
||||
func (c *appService) Regions(ctx context.Context, in *RegionsRequest, opts ...client.CallOption) (*RegionsResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "App.Regions", in)
|
||||
out := new(RegionsResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appService) Run(ctx context.Context, in *RunRequest, opts ...client.CallOption) (*RunResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "App.Run", in)
|
||||
out := new(RunResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appService) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "App.Update", in)
|
||||
out := new(UpdateResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "App.Delete", in)
|
||||
out := new(DeleteResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appService) Status(ctx context.Context, in *StatusRequest, opts ...client.CallOption) (*StatusResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "App.Status", in)
|
||||
out := new(StatusResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "App.List", in)
|
||||
out := new(ListResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appService) Resolve(ctx context.Context, in *ResolveRequest, opts ...client.CallOption) (*ResolveResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "App.Resolve", in)
|
||||
out := new(ResolveResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -82,13 +148,25 @@ func (c *appService) Vote(ctx context.Context, in *VoteRequest, opts ...client.C
|
||||
|
||||
type AppHandler interface {
|
||||
Reserve(context.Context, *ReserveRequest, *ReserveResponse) error
|
||||
Vote(context.Context, *VoteRequest, *VoteResponse) error
|
||||
Regions(context.Context, *RegionsRequest, *RegionsResponse) error
|
||||
Run(context.Context, *RunRequest, *RunResponse) error
|
||||
Update(context.Context, *UpdateRequest, *UpdateResponse) error
|
||||
Delete(context.Context, *DeleteRequest, *DeleteResponse) error
|
||||
Status(context.Context, *StatusRequest, *StatusResponse) error
|
||||
List(context.Context, *ListRequest, *ListResponse) error
|
||||
Resolve(context.Context, *ResolveRequest, *ResolveResponse) error
|
||||
}
|
||||
|
||||
func RegisterAppHandler(s server.Server, hdlr AppHandler, opts ...server.HandlerOption) error {
|
||||
type app interface {
|
||||
Reserve(ctx context.Context, in *ReserveRequest, out *ReserveResponse) error
|
||||
Vote(ctx context.Context, in *VoteRequest, out *VoteResponse) error
|
||||
Regions(ctx context.Context, in *RegionsRequest, out *RegionsResponse) error
|
||||
Run(ctx context.Context, in *RunRequest, out *RunResponse) error
|
||||
Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error
|
||||
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
|
||||
Status(ctx context.Context, in *StatusRequest, out *StatusResponse) error
|
||||
List(ctx context.Context, in *ListRequest, out *ListResponse) error
|
||||
Resolve(ctx context.Context, in *ResolveRequest, out *ResolveResponse) error
|
||||
}
|
||||
type App struct {
|
||||
app
|
||||
@@ -105,6 +183,30 @@ func (h *appHandler) Reserve(ctx context.Context, in *ReserveRequest, out *Reser
|
||||
return h.AppHandler.Reserve(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *appHandler) Vote(ctx context.Context, in *VoteRequest, out *VoteResponse) error {
|
||||
return h.AppHandler.Vote(ctx, in, out)
|
||||
func (h *appHandler) Regions(ctx context.Context, in *RegionsRequest, out *RegionsResponse) error {
|
||||
return h.AppHandler.Regions(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *appHandler) Run(ctx context.Context, in *RunRequest, out *RunResponse) error {
|
||||
return h.AppHandler.Run(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *appHandler) Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error {
|
||||
return h.AppHandler.Update(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *appHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error {
|
||||
return h.AppHandler.Delete(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *appHandler) Status(ctx context.Context, in *StatusRequest, out *StatusResponse) error {
|
||||
return h.AppHandler.Status(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *appHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
|
||||
return h.AppHandler.List(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *appHandler) Resolve(ctx context.Context, in *ResolveRequest, out *ResolveResponse) error {
|
||||
return h.AppHandler.Resolve(ctx, in, out)
|
||||
}
|
||||
|
||||
@@ -6,20 +6,98 @@ option go_package = "./proto;app";
|
||||
|
||||
service App {
|
||||
rpc Reserve(ReserveRequest) returns (ReserveResponse) {}
|
||||
rpc Vote(VoteRequest) returns (VoteResponse) {}
|
||||
rpc Regions(RegionsRequest) returns (RegionsResponse) {}
|
||||
rpc Run(RunRequest) returns (RunResponse) {}
|
||||
rpc Update(UpdateRequest) returns (UpdateResponse) {}
|
||||
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
|
||||
rpc Status(StatusRequest) returns (StatusResponse) {}
|
||||
rpc List(ListRequest) returns (ListResponse) {}
|
||||
rpc Resolve(ResolveRequest) returns (ResolveResponse) {}
|
||||
}
|
||||
|
||||
// Vote to have the App api launched faster!
|
||||
message VoteRequest {
|
||||
// optional message
|
||||
string message = 1;
|
||||
message Service {
|
||||
// unique id
|
||||
string id = 1;
|
||||
// name of the app
|
||||
string name = 2;
|
||||
// source repository
|
||||
string repo = 3;
|
||||
// branch of code
|
||||
string branch = 4;
|
||||
// region running in
|
||||
string region = 5;
|
||||
// port running on
|
||||
int32 port = 6;
|
||||
// status of the app
|
||||
string status = 7;
|
||||
// app url
|
||||
string url = 8;
|
||||
// time of creation
|
||||
string created = 9;
|
||||
// last updated
|
||||
string updated = 10;
|
||||
// associated env vars
|
||||
map<string,string> env_vars = 11;
|
||||
// custom domains
|
||||
repeated string custom_domains = 12;
|
||||
}
|
||||
|
||||
message VoteResponse {
|
||||
// response message
|
||||
string message = 2;
|
||||
// Delete an app
|
||||
message DeleteRequest {
|
||||
// name of the app
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message DeleteResponse {}
|
||||
|
||||
// List all the apps
|
||||
message ListRequest {
|
||||
}
|
||||
|
||||
message ListResponse {
|
||||
// all the apps
|
||||
repeated Service services = 1;
|
||||
}
|
||||
|
||||
// Run an app
|
||||
message RunRequest {
|
||||
// name of the app
|
||||
string name = 1;
|
||||
// source repository
|
||||
string repo = 2;
|
||||
// branch. defaults to master
|
||||
string branch = 3;
|
||||
// region to run in
|
||||
string region = 4;
|
||||
// port to run on
|
||||
int32 port = 5;
|
||||
// associatede env vars to pass in
|
||||
map<string,string> env_vars = 6;
|
||||
}
|
||||
|
||||
message RunResponse {
|
||||
// The running service
|
||||
Service service = 1;
|
||||
}
|
||||
|
||||
// Update the app
|
||||
message UpdateRequest {
|
||||
// name of the app
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message UpdateResponse {
|
||||
}
|
||||
|
||||
|
||||
// Return the support regions
|
||||
message RegionsRequest {}
|
||||
|
||||
message RegionsResponse {
|
||||
repeated string regions = 1;
|
||||
}
|
||||
|
||||
// Reservation represents a reserved app instance
|
||||
message Reservation {
|
||||
// name of the app
|
||||
string name = 1;
|
||||
@@ -33,12 +111,35 @@ message Reservation {
|
||||
string expires = 5;
|
||||
}
|
||||
|
||||
// Reserve your app name
|
||||
// Reserve apps beyond the free quota. Call Run after.
|
||||
message ReserveRequest {
|
||||
// name of your app e.g helloworld
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message ReserveResponse {
|
||||
// The app reservation
|
||||
Reservation reservation = 1;
|
||||
}
|
||||
|
||||
// Get the status of an app
|
||||
message StatusRequest {
|
||||
// name of the app
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message StatusResponse {
|
||||
// running service info
|
||||
Service service = 1;
|
||||
}
|
||||
|
||||
// Resolve an app by id to its raw backend endpoint
|
||||
message ResolveRequest {
|
||||
// the service id
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message ResolveResponse {
|
||||
// the end provider url
|
||||
string url = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user