types

package
v0.0.0-...-5a5a6b2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultNatsURL is a default NATS URL
	DefaultNatsURL = "nats://nats:4222"
	// DefaultNatsMaxReconnect is a default NATS Max Reconnect Count
	DefaultNatsMaxReconnect = 6
	// DefaultNatsReconnectWait is a default NATS Reconnect Wait Time in Seconds
	DefaultNatsReconnectWait = 10
	// DefaultNatsRequestTimeout is a default NATS Request Timeout in Seconds
	DefaultNatsRequestTimeout = 30

	// DefaultNatsQueueGroup is a default NATS Queue Group
	DefaultNatsQueueGroup = "js2allocation_queue_group"
	// DefaultNatsWildcardSubject is a default NATS subject to subscribe
	DefaultNatsWildcardSubject = string(cacao_common_service.NatsSubjectJS2Allocation) + ".>"

	// DefaultNatsClientID is a default NATS Client ID
	DefaultNatsClientID = "js2allocation-service"
	// DefaultNatsClusterID is a default NATS Cluster ID
	DefaultNatsClusterID = "cacao-cluster"

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

	// DefaultMongoDBURL is a default MongoDB URL
	DefaultMongoDBURL = "mongodb://localhost:27017"
	// DefaultMongoDBName is a default MongoDB Name
	DefaultMongoDBName = "cacao-js2allocation"
	// DefaultJS2AllocationMongoDBUserCollectionName is a default MongoDB Collection Name for User
	DefaultJS2AllocationMongoDBUserCollectionName = "js2allocation_user"
	// DefaultJS2AllocationMongoDBProjectCollectionName is a default MongoDB Collection Name for Project
	DefaultJS2AllocationMongoDBProjectCollectionName = "js2allocation_project"
	// DefaultUserCacheExpirationTime is a default cache expiration time for JS2 User cache
	DefaultUserCacheExpirationTime = 1 * time.Hour
	// DefaultProjectCacheExpirationTime is a default cache expiration time for JS2 Project cache
	DefaultProjectCacheExpirationTime = 1 * time.Hour
)
View Source
const (
	// DefaultChannelBufferSize is a default buffer size for a channel used between adapters and domain
	DefaultChannelBufferSize = 100
)

Variables

This section is empty.

Functions

func ConvertProjectToListItemModel

func ConvertProjectToListItemModel(project JS2Project) cacao_common_service.JS2ProjectModel

ConvertProjectToListItemModel converts JS2Project to JS2ProjectListItemModel

Types

type Config

type Config struct {
	// NATS
	Messaging messaging2.NatsStanMsgConfig

	// MongoDB
	MongoDBConfig                             cacao_common_db.MongoDBConfig
	JS2AllocationMongoDBUserCollectionName    string
	JS2AllocationMongoDBProjectCollectionName string

	// Deprecated: this service no longer uses TAS api.
	TASApiUsername string `envconfig:"TACC_API_USER"`
	// Deprecated: this service no longer uses TAS api.
	TASApiPassword string `envconfig:"TACC_API_PASS"`

	// Cache
	UserCacheExpirationTime    time.Duration
	ProjectCacheExpirationTime time.Duration

	FilterOutInvalidCredential bool `envconfig:"FILTER_OUT_INVALID_CREDENTIAL"`
}

Config is the configuration settings, which can be used by the Domain object or Adapters

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 JS2Allocation

type JS2Allocation struct {
	ID               string    `bson:"id" json:"id,omitempty"`
	Start            time.Time `bson:"start" json:"start,omitempty"`
	End              time.Time `bson:"end" json:"end,omitempty"`
	ProjectCode      string    `bson:"project_code" json:"project_code,omitempty"`
	Resource         string    `bson:"resource" json:"resource,omitempty"`
	ComputeAllocated float64   `bson:"compute_allocated" json:"compute_allocated,omitempty"`
	StorageAllocated float64   `bson:"storage_allocated" json:"storage_allocated,omitempty"`
	ComputeUsed      float64   `bson:"compute_used" json:"compute_used,omitempty"`
}

JS2Allocation is a struct for JS2 Allocation information Deprecated: this is for TAS API for JS1

type JS2AllocationChannelReply

type JS2AllocationChannelReply struct {
	Data  []JS2Project
	Error error
}

JS2AllocationChannelReply is a response struct used between adapters and domain

type JS2AllocationChannelRequest

type JS2AllocationChannelRequest struct {
	Actor     string
	Emulator  string
	Operation common.QueryOp
	NoCache   bool
	Response  chan<- JS2AllocationChannelReply // channel created by adapter(or other caller) and will receive the response
}

JS2AllocationChannelRequest is a request struct used between adapters and domain

type JS2PI

type JS2PI struct {
	Username  string `bson:"username" json:"username,omitempty"`
	FirstName string `bson:"firstname" json:"firstname,omitempty"`
	LastName  string `bson:"lastname" json:"lastname,omitempty"`
}

JS2PI is a struct for storing JS2 PI information Deprecated: this is for TAS API for JS1

type JS2Project

type JS2Project struct {
	ID          common.ID       `bson:"_id" json:"id,omitempty"`
	Owner       string          `bson:"owner" json:"owner,omitempty"`
	Title       string          `bson:"title" json:"title,omitempty"`
	Description string          `bson:"description" json:"description,omitempty"`
	PI          JS2PI           `bson:"pi" json:"pi,omitempty"`
	Allocations []JS2Allocation `bson:"allocations" json:"allocations,omitempty"`
	RetrivedAt  time.Time       `bson:"retrieved_at" json:"retrieved_at,omitempty"`
}

JS2Project is a struct for storing JS2 Project information Deprecated: this is for TAS API for JS1

type NewJS2Allocation

type NewJS2Allocation struct {
	Title                 string    `json:"title"`
	Description           string    `json:"description"`
	Abstract              string    `json:"abstract"`
	Resource              string    `json:"resource"`
	ServiceUnitsAllocated float64   `json:"service_units_allocated"`
	ServiceUnitsUsed      float64   `json:"service_units_used"`
	StartDate             time.Time `json:"start_date"`
	EndDate               time.Time `json:"end_date"`
	Active                int       `json:"active"`
}

NewJS2Allocation is a single allocation from js2 accounting API. https://gitlab.com/jetstream-cloud/accounting-api/-/blob/main/openapi.yml TODO rename (NewJS2Allocation => JS2Allocation) this after removing the TAS api stuff

func (*NewJS2Allocation) IsInactiveOrExpired

func (j *NewJS2Allocation) IsInactiveOrExpired(now time.Time) bool

IsInactiveOrExpired checks if allocation is inactive or expired.

func (*NewJS2Allocation) UnmarshalJSON

func (j *NewJS2Allocation) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshal JSON into NewJS2Allocation. This use a staging struct to convert time and service units.

type Session

type Session struct {
	TID             common.TransactionID
	SessionActor    string `json:"actor"`
	SessionEmulator string `json:"emulator,omitempty"`
}

Session contains info for a request session

func (Session) ToServiceActor

func (s Session) ToServiceActor() service.Actor

ToServiceActor ...

Jump to

Keyboard shortcuts

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