Skip to content

Instantly share code, notes, and snippets.

Point to point route ETAs

ETAs Service

This is the ETAs service. It provides ETAs for single-pickup, multi-dropoff routes. It takes into account time and traffic.

Current limitations: • Only supports "Driving" (not walking, cycling) • Does not optimize route

@asim
asim / api.md
Last active December 10, 2020 14:39

Settings > API Tokens

Your API Token

Below find your API token

eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoidXNlciIsInNjb3BlcyI6bnVsbCwibWV0YWRhdGEiOnt9LCJuYW1lIjoiYXN
pbSIsImV4cCI6MTYwNzYxMTc5NywiaXNzIjoibWljcm8iLCJzdWIiOiJhc2ltIn0.H2MtvKwga5SwS_lYRMHKuK_tamjSeonQZHR65_0guQKQ
-NFVoJI3mbU2tPebyEbDLk8b8YdLpqjoLJGZ420xhT5Vuw0UMDr8tPh749EJHY0Zhf4hCGDOu66IIa0rb8uDmDzEN1glpkIu4gBeTVmgHmyWr
func (p *Posts) Delete(ctx context.Context, req *proto.DeleteRequest, rsp *proto.DeleteResponse) error {
logger.Info("Received Post.Delete request")
return p.db.Delete(model.Equals("id", req.Id))
}
func (p *Posts) Query(ctx context.Context, req *proto.QueryRequest, rsp *proto.QueryResponse) error {
var q model.Query
if len(req.Slug) > 0 {
logger.Infof("Reading post by slug: %v", req.Slug)
q = p.slugIndex.ToQuery(req.Slug)
} else if len(req.Id) > 0 {
logger.Infof("Reading post by id: %v", req.Id)
q = p.idIndex.ToQuery(req.Id)
} else {
q = p.createdIndex.ToQuery(nil)
// Query posts. Acts as a listing when no id or slug provided.
// Gets a single post by id or slug if any of them provided.
message QueryRequest {
string id = 1;
string slug = 2;
string tag = 3;
int64 offset = 4;
int64 limit = 5;
}
func (p *Posts) Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.SaveResponse) error {
logger.Info("Received Posts.Save request")
post := &proto.Post{
Id: req.Id,
Title: req.Title,
Content: req.Content,
Slug: req.Slug,
Created: time.Now().Unix(),
}
if req.Slug == "" {
package handler
import (
"context"
"time"
"github.com/micro/dev/model"
"github.com/micro/go-micro/errors"
"github.com/micro/micro/v3/service/logger"
"github.com/micro/micro/v3/service/store"
package main
import (
"posts/handler"
"github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/logger"
)
func main() {
syntax = "proto3";
package posts;
service Posts {
rpc Save(SaveRequest) returns (SaveResponse) {}
rpc Query(QueryRequest) returns (QueryResponse) {}
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
}
package main
import (
"github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/logger"
"github.com/micro/services/helloworld/handler"
helloworld "github.com/micro/services/helloworld/proto"
)
type Helloworld struct{}