types

package
v0.0.0-...-d3e8332 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNatsQueueGroup is a default NATS Queue Group
	DefaultNatsQueueGroup = "provider_queue_group"
	// DefaultNatsWildcardSubject is a default NATS subject to subscribe
	DefaultNatsWildcardSubject = "cyverse.provider.>"

	// DefaultNatsClientID is a default NATS Client ID
	DefaultNatsClientID = "providers-service"

	// DefaultNatsDurableName is a default NATS Durable Name
	DefaultNatsDurableName = "provider_durable"

	// DefaultMongoDBURL is a default MongoDB URL
	DefaultMongoDBURL = "mongodb://localhost:27017"
	// DefaultMongoDBName is a default MongoDB Name
	DefaultMongoDBName = "cacao"
	// DefaultProviderMongoDBCollectionName is a default MongoDB Collection Name
	DefaultProviderMongoDBCollectionName = "provider"
)
View Source
const (
	MaxProviderNameLength = 100
	MaxProviderTypeLength = 20
	MaxProviderURLLength  = 2048
)

constants that specify some constraints on provider fields

View Source
const DefaultListLimit = 500

DefaultListLimit is the default limit (# of providers) on list operation in storage

View Source
const ProviderTypeForTesting service.ProviderType = "__test__"

ProviderTypeForTesting ...

Variables

This section is empty.

Functions

func NewCacaoNotFoundError

func NewCacaoNotFoundError(providerID common.ID) service.CacaoError

NewCacaoNotFoundError returns a NotFoundError, this is used to have a consistent error message for NotFoundError.

Types

type Config

type Config struct {
	LogLevel   string
	OnlyAdmins bool // set to true to restrict crud events to admins
	// NATS
	Messaging messaging2.NatsStanMsgConfig

	// MongoDB
	MongoDBConfig                 db.MongoDBConfig
	ProviderMongoDBCollectionName string
}

Config ...

func (*Config) Override

func (c *Config) Override()

Override ...

func (*Config) ProcessDefaults

func (c *Config) ProcessDefaults()

ProcessDefaults will take a Config object and process the config object further, including populating any null values

type Provider

type Provider struct {
	ID     common.ID            `bson:"_id"`
	Name   string               `bson:"name"`
	Type   service.ProviderType `bson:"type"`
	URL    string               `bson:"url"`
	Owner  string               `bson:"owner"`
	Public bool                 `bson:"public"`
	// Shared means only shared with some users, only private provider can be shared.
	// TODO add fields (or separate document) to specify whom to share with
	Shared bool `bson:"shared"`
	// ID of the deployment that this provider is created from, leave empty is not created from deployment.
	// Example use case is kubernetes provider created from a terraform deployment.
	FromDeployment common.ID `bson:"from_deployment"`
	CreatedAt      time.Time `bson:"created_at"`
	UpdatedAt      time.Time `bson:"updated_at"`
	// username that last updated the provider
	UpdatedBy string                 `bson:"updated_by"`
	Metadata  map[string]interface{} `bson:"metadata"`
}

Provider is the internal storage format.

Keeping the storage struct internal instead of in cacao-common allow us to change storage format without changing the service client.

func FromServiceModel

func FromServiceModel(p service.ProviderModel) Provider

FromServiceModel converts from service model(the format send over message bus) to internal storage model

func (*Provider) ToServiceModel

func (p *Provider) ToServiceModel() service.ProviderModel

ToServiceModel converts internal storage model to service model(the format send over message bus)

type ProviderRequest

type ProviderRequest struct {
	service.ProviderModel
	Operation        string
	UpdateFieldNames []string // list field names to update, this is used only when operation is Update
	TransactionID    common.TransactionID
	Response         chan ProviderResponse // channel created by adapter(or other caller) and will receive the response
}

ProviderRequest is a bundle for domain data and an event/query operation on that data.

type ProviderResponse

type ProviderResponse struct {
	Data  []service.ProviderModel
	Error error
}

ProviderResponse ...

type ProviderUpdate

type ProviderUpdate struct {
	Name     *string                `bson:"name"`
	Type     *service.ProviderType  `bson:"type"`
	URL      *string                `bson:"url"`
	Public   *bool                  `bson:"public"`
	Shared   *bool                  `bson:"shared"`
	Metadata map[string]interface{} `bson:"metadata"`

	UpdatedAt time.Time `bson:"updated_at"`
	UpdatedBy string    `bson:"updated_by"`
}

ProviderUpdate ...

func (*ProviderUpdate) ToBSON

func (u *ProviderUpdate) ToBSON() bson.M

ToBSON ...

Jump to

Keyboard shortcuts

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