Humm.. I wrote a reply but it seems it only reached Justin and not this 
group.
Also I have not received other replies via email.

Ok...

Ayan, no that's alright it was storage.UserModelInterface
and I know what you're all saying but I saw no other way to make them type 
agnostic and I'm a fan of explicitly calling things what they are 
especially when I'm experimenting.
And it's not really the point.

I tried Justin's idea or rather the idea that resulted because of Justin's 
reply
and
https://github.com/dalu/forum/tree/6bb47c27c606b30f91412b48b1af561abe0f5558/server/storage/mongo/service
it's not thread safe

because it operates on the passed instance of the concrete model.
In 
https://github.com/dalu/forum/blob/6bb47c27c606b30f91412b48b1af561abe0f5558/server/storage/mongo/service/user_test.go#L24
I initialize a service with a new user storage and a pointer to a 
(mongo)model.User
In 
https://github.com/dalu/forum/blob/6bb47c27c606b30f91412b48b1af561abe0f5558/server/storage/mongo/service/user.go#L21
I copy the pointer for the lack of better means to create a new copy, 
shallow copy (a := *b) doesn't work because it's an interface

So I think I'll just call it quits and go concrete up to the service level.
Yeah Egon ID is the lowest common denominator (that brainfart moment on 
reddit was me ;) ). And it would probably work but I'm not risking it for 
this one :)
For bson I can use the getter/setter interfaces but idk if there's 
something like it for other databases, so I'll just go abstract (or 
interface) on the service level.
And the storage/repository and model will be concrete.
UserService will be an interface
ThreadService will be an interface and so on
and there will be MongoUserService PostgresUserService and so on.
and implementing new databases will be a pain in the butt.
But that's Go for you :)

Thanks for feedback all.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to