Skip to content

Commit

Permalink
shortlink: backend implementation (#2074)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecutalo authored Mar 3, 2022
1 parent 1c8f625 commit 0aa0f85
Show file tree
Hide file tree
Showing 9 changed files with 895 additions and 8 deletions.
14 changes: 14 additions & 0 deletions api/config/service/shortlink/v1/shortlink.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";

package clutch.config.service.shortlink.v1;

option go_package = "github.com/lyft/clutch/backend/api/config/service/shortlink/v1;shortlinkv1";

message Config {
// Chars is the list of characters that will be used when generating the random string.
// By default its set to [a-zA-Z0-9]
string shortlink_chars = 1;
// This sets the length of the random string being generated.
// By default its set to 10
int64 shortlink_length = 2;
}
165 changes: 165 additions & 0 deletions backend/api/config/service/shortlink/v1/shortlink.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 138 additions & 0 deletions backend/api/config/service/shortlink/v1/shortlink.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions backend/gateway/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
kinesismod "github.com/lyft/clutch/backend/module/kinesis"
proxymod "github.com/lyft/clutch/backend/module/proxy"
resolvermod "github.com/lyft/clutch/backend/module/resolver"
shortlinkmod "github.com/lyft/clutch/backend/module/shortlink"
"github.com/lyft/clutch/backend/module/sourcecontrol"
topologymod "github.com/lyft/clutch/backend/module/topology"
"github.com/lyft/clutch/backend/resolver"
Expand All @@ -48,6 +49,7 @@ import (
feedbackservice "github.com/lyft/clutch/backend/service/feedback"
"github.com/lyft/clutch/backend/service/github"
k8sservice "github.com/lyft/clutch/backend/service/k8s"
shortlinkservice "github.com/lyft/clutch/backend/service/shortlink"
sourcegraphservice "github.com/lyft/clutch/backend/service/sourcegraph"
"github.com/lyft/clutch/backend/service/temporal"
topologyservice "github.com/lyft/clutch/backend/service/topology"
Expand Down Expand Up @@ -79,6 +81,7 @@ var Modules = module.Factory{
redisexperimentation.Name: redisexperimentation.New,
resolvermod.Name: resolvermod.New,
serverexperimentation.Name: serverexperimentation.New,
shortlinkmod.Name: shortlinkmod.New,
slackbotmod.Name: slackbotmod.New,
sourcecontrol.Name: sourcecontrol.New,
topologymod.Name: topologymod.New,
Expand All @@ -99,6 +102,7 @@ var Services = service.Factory{
k8sservice.Name: k8sservice.New,
loggingsink.Name: loggingsink.New,
pgservice.Name: pgservice.New,
shortlinkservice.Name: shortlinkservice.New,
slack.Name: slack.New,
sourcegraphservice.Name: sourcegraphservice.New,
temporal.Name: temporal.New,
Expand Down
19 changes: 17 additions & 2 deletions backend/module/shortlink/shortlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,24 @@ func newShortlinkAPI(svc shortlink.Service) shortlinkv1.ShortlinkAPIServer {
}

func (s *shortlinkAPI) Create(ctx context.Context, req *shortlinkv1.CreateRequest) (*shortlinkv1.CreateResponse, error) {
return nil, errors.New("not implemented")
hash, err := s.shortlink.Create(ctx, req.Path, req.State)
if err != nil {
return nil, err
}

return &shortlinkv1.CreateResponse{
Hash: hash,
}, nil
}

func (s *shortlinkAPI) Get(ctx context.Context, req *shortlinkv1.GetRequest) (*shortlinkv1.GetResponse, error) {
return nil, errors.New("not implemented")
path, state, err := s.shortlink.Get(ctx, req.Hash)
if err != nil {
return nil, err
}

return &shortlinkv1.GetResponse{
Path: path,
State: state,
}, nil
}
Loading

0 comments on commit 0aa0f85

Please sign in to comment.