db

package
v0.0.0-...-2119b44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

This is an example of a repository

This is an example of a repository

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouteRepo

func NewRouteRepo(db sql.Db) *routeRepo

func NewServiceRepo

func NewServiceRepo(db sql.Db) *serviceRepo

Types

type Route

type Route struct {
	gorm.Model
	Key string `gorm:"unique;type:string;uniqueIndex:route_idx_case_insensetive,expression:lower(key);not null"` /* Routing key */

}

type RouteRepo

type RouteRepo interface {
	Add(key string) (*Route, error)
	Remove(key string) error
	List() ([]Route, error)
	Get(key string) (*Route, error)
}

declare interface so that we can mock it

type Service

type Service struct {
	gorm.Model
	Name        string `gorm:"unique;type:string;uniqueIndex:service_idx_case_insensetive,expression:lower(name);not null"` /* name of the service */
	InstanceId  string `gorm:"unique;type:string;"`
	ServiceUuid string `gorm:"type:uuid;default:gen_random_uuid();unique"` //default:uuid_generate_v3                                                                          /* returned by msg client on registration */
	MsgBusUri   string /* grpc srever url to create grpc client*/
	ListQueue   string
	PublQueue   string
	Exchange    string
	ServiceUri  string
	GrpcTimeout uint32
	Routes      []Route `gorm:"many2many:service_routes;"`
}

type ServiceRepo

type ServiceRepo interface {
	Register(service *Service) (*Service, error)
	UnRegister(serviceId string) error
	Get(serviceUuid string) (*Service, error)
	GetRoutes(serviceId string) ([]Route, error)
	List() ([]Service, error)
	AddRoute(s *Service, rt *Route) error
	RemoveRoutes(service *Service) error
}

declare interface so that we can mock it

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL