Best way to upload relationships #92
-
What's considered the best way to load relationships, especially concerning "Edges" or added relationship data. Example 1: type Repository struct {
gogm.BaseNode
Name string `gogm:"name=name" json:"name"`
RepositoryId string `gogm:"name=repositoryid" json:"repository_id"`
GitUrl string `gogm:"name=url" json:"git_url"`
Tags []string `gogm:"name=tags;properties" json:"tags"`
Description string `gogm:"name=description" json:"description"`
GitlabDirectoryPath string `gogm:"name=path" json:"path"`
DocumentationLink string `gogm:"name=documentation" json:"documentation_link"`
// Incoming
OperationsTeam *OperationsTeam `gogm:"direction=incoming;relationship=SUPPORTS" json:"-"`
DevelopmentTeam *DevelopmentTeam `gogm:"direction=incoming;relationship=OWNS" json:"-"`
// Outgoing
Deploys []*Service `gogm:"direction=outgoing;relationship=DEPLOYS" json:"-"`
}
type Service struct {
gogm.BaseNode
Name string `gogm:"name=name" json:"name"`
NexusLink string `gogm:"name=nexus" json:"nexus_image"`
Type string `gogm:"name=type" json:"type"` // ENUM: API, NonExposingService, Script, SSIS, Docs
ConfigLocation string `gogm:"name=config_location" json:"config_location"`
DeploymentStyle string `gogm:"name=deployment" json:"deployment_style"`
HomeFolder string `gogm:"name=folder" json:"home_folder"`
// Incoming
ParentRepository *Repository `gogm:"direction=incoming;relationship=DEPLOYS" json:"-"`
// Outgoing
ExposedEndpoints []*Endpoint `gogm:"direction=outgoing;relationship=EXPOSES" json:"-"`
// Edge
DependsOn []*DependsOnEdge `gogm:"direction=outgoing;relationship=DEPENDS_ON" json:"-"`
} Is it best to load Repository.Deploys with Example 2: type Service struct {
gogm.BaseNode
Name string `gogm:"name=name" json:"name"`
NexusLink string `gogm:"name=nexus" json:"nexus_image"`
Type string `gogm:"name=type" json:"type"` // ENUM: API, NonExposingService, Script, SSIS, Docs
ConfigLocation string `gogm:"name=config_location" json:"config_location"`
DeploymentStyle string `gogm:"name=deployment" json:"deployment_style"`
HomeFolder string `gogm:"name=folder" json:"home_folder"`
// Incoming
ParentRepository *Repository `gogm:"direction=incoming;relationship=DEPLOYS" json:"-"`
// Outgoing
ExposedEndpoints []*Endpoint `gogm:"direction=outgoing;relationship=EXPOSES" json:"-"`
// Edge
DependsOn []*DependsOnEdge `gogm:"direction=outgoing;relationship=DEPENDS_ON" json:"-"`
// Dep []*DependsOnEdge `gogm:"direction=incoming;relationship=DEPENDS_ON" json:"-"`
}
// Edge for service to service dependencies
type DependsOnEdge struct {
gogm.BaseNode
Start *Service `json:"start_service"`
End *Endpoint `json:"-"`
Criticality string `gogm:"name=criticality"`
Name string `gogm:"name=name" json:"name"`
// category of system: Database, API, Script, NonExposing Service, Infrastructure,
// SSIS, NiFi Flow
SystemCategory string `gogm:"name=system_category" json:"system_category"`
// type of system: SQL Server, Oracle, Kafka, Logstash, Elastic, MySQL, Mongo
SystemSubType string `gogm:"name=system_subtype" json:"system_subtype"`
// type of auth: basic, certificate, none
AuthType string `gogm:"name=auth_type" json:"auth_type"`
Environment string `gogm:"name=environment" json:"environment"`
Connection string `gogm:"name=connection" json:"connection"`
ServiceAccount string `gogm:"name=service_account" json:"user"`
EscalationTeamDl string `gogm:"name=escalation" json:"escalation_team_dl"`
// Filler
FillerEndpoint []*Endpoint `json:"healthchecks"`
}
type Endpoint struct {
gogm.BaseNode
Name string `gogm:"name=name" json:"name"`
InfrastructureLocation string `gogm:"name=location" json:"infrastructure_location"` // ?
Datacenter string `gogm:"name=datacenter" json:"data_center"`
BaseUrl string `gogm:"name=url" json:"base_url"`
Environment string `gogm:"name=environment" json:"environment"`
// Healthcheck data
Healtcheck_RequestType string `gogm:"name=type" json:"request_type"`
Healtcheck_UrlToAppend string `gogm:"name=url_to_append" json:"url_to_append"`
Healtcheck_Metadata string `gogm:"name=metadata" json:"metadata"` // should be a struct but idk how to Go :')
Healtcheck_Headers string `gogm:"name=header" json:"header"`
// Incoming
ExposedByService *Service `gogm:"direction=incoming;relationship=EXPOSES" json:"-"`
Dep []*DependsOnEdge `gogm:"direction=incoming;relationship=DEPENDS_ON" json:"-"`
} Kind of the same question here, what's the best order to load these in? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You could structure your query either way. Realistically, depending on your query, and how the database is indexed, one query could be faster then the other, but it would not effect how GoGM decodes the data. My advice, is to structure your query to support the code that consumes it, if the primary object is the list of |
Beta Was this translation helpful? Give feedback.
You could structure your query either way. Realistically, depending on your query, and how the database is indexed, one query could be faster then the other, but it would not effect how GoGM decodes the data.
My advice, is to structure your query to support the code that consumes it, if the primary object is the list of
Service
objects connected to aRepository
, I'd structure your query accordingly.