Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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