The object model

The object model is the collection of all the interfaces and related data types that are implemented by the services. I chose to put all of them in a single package: github.com/the-gigi/delinkcious/pkg/object_model. It contains two files: interfaces.go and types.go.

The interfaces.go file contains the interfaces for the three Delinkcious services:

package object_model

type LinkManager interface {
GetLinks(request GetLinksRequest) (GetLinksResult, error)
AddLink(request AddLinkRequest) error
UpdateLink(request UpdateLinkRequest) error
DeleteLink(username string, url string) error
}

type UserManager interface {
Register(user User) error
Login(username string, authToken string) (session string, err error)
Logout(username string, session string) error
}

type SocialGraphManager interface {
Follow(followed string, follower string) error
Unfollow(followed string, follower string) error

GetFollowing(username string) (map[string]bool, error)
GetFollowers(username string) (map[string]bool, error)
}

type LinkManagerEvents interface {
OnLinkAdded(username string, link *Link)
OnLinkUpdated(username string, link *Link)
OnLinkDeleted(username string, url string)
}

The types.go file contains the structs that are used in the signatures of the various interface methods:

package object_model

import "time"

type Link struct {
Url string
Title string
Description string
Tags map[string]bool
CreatedAt time.Time
UpdatedAt time.Time
}

type GetLinksRequest struct {
UrlRegex string
TitleRegex string
DescriptionRegex string
Username string
Tag string
StartToken string
}

type GetLinksResult struct {
Links []Link
NextPageToken string
}

type AddLinkRequest struct {
Url string
Title string
Description string
Username string
Tags map[string]bool
}

type UpdateLinkRequest struct {
Url string
Title string
Description string
Username string
AddTags map[string]bool
RemoveTags map[string]bool
}

type User struct {
Email string
Name string
}

The object_model package is just using basic Go types, standard library types (time.Time), and user-defined types for the Delinkcious domain. It is all pure Go. At this level, there is no dependency or awareness of networking, APIs, microservices, or Go kit.