Created
May 7, 2021 14:59
-
-
Save lusis/181a80b975e9a7551e66187cfc36db3a to your computer and use it in GitHub Desktop.
Revisions
-
lusis created this gist
May 7, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ package fooservice import ( "github.com/segmentio/ksuid" idgen "github.com/lusis/foobar/idgen" pb "github.com/lusis/foobar/pb" storer "github.com/lusis/foobar/storer" ) // FooService implements the pb.FooService type FooService struct { pb.UnimplementedFooServiceServer store storer.FooEntriesStorer idFunc idgen.IDFunc } // New ... func New(store storer.FooEntriesStorer) (*FooService, error) { return &FooService{ store: store, idFunc: idgen.DefaultIDFunc, }, nil } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ package idgen type IDFunc func() string func DefaultIDFunc() string { return ksuid.New().String() } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ package fooservice import ( "github.com/segmentio/ksuid" pb "github.com/lusis/foobar/pb" storer "github.com/lusis/foobar/storer" ) // FooService implements the pb.FooService type FooService struct { pb.UnimplementedFooServiceServer store storer.FooEntriesStorer idFunc func() string } func defaultIDFunc() string { return ksuid.New().String() } // New ... func New(store storer.FooEntriesStorer) (*FooService, error) { return &FooService{ store: store, idFunc: defaultIDFunc, }, nil }