Created
May 7, 2021 14:59
-
-
Save lusis/181a80b975e9a7551e66187cfc36db3a to your computer and use it in GitHub Desktop.
This file contains 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 characters
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 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 characters
package idgen | |
type IDFunc func() string | |
func DefaultIDFunc() string { | |
return ksuid.New().String() | |
} |
This file contains 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 characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment