Skip to content

Instantly share code, notes, and snippets.

@lusis
Created May 7, 2021 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lusis/181a80b975e9a7551e66187cfc36db3a to your computer and use it in GitHub Desktop.
Save lusis/181a80b975e9a7551e66187cfc36db3a to your computer and use it in GitHub Desktop.
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
}
package idgen
type IDFunc func() string
func DefaultIDFunc() string {
return ksuid.New().String()
}
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