mongodb

package
v0.0.0-...-1b34132 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MonitorInterval30Seconds = 30
	MonitorInterval60Seconds = 60
)

Variables

This section is empty.

Functions

func Connect

func Connect(uri, dbName string)

func HealthCheckRecordCol

func HealthCheckRecordCol() *mongo.Collection

func MonitorCol

func MonitorCol() *mongo.Collection

func NewObjectID

func NewObjectID() primitive.ObjectID

func ObjectIDFromString

func ObjectIDFromString(id string) (primitive.ObjectID, error)

func RunTransaction

func RunTransaction(ctx *appcontext.AppContext, fn func(sessionContext mongo.SessionContext) error) error

RunTransaction ...

func UserCol

func UserCol() *mongo.Collection

Types

type HealthCheckRecord

type HealthCheckRecord struct {
	ID               primitive.ObjectID      `bson:"_id"`
	Owner            primitive.ObjectID      `bson:"owner"`
	Type             MonitorType             `bson:"type"`
	Status           HealthCheckRecordStatus `bson:"status"`
	Code             string                  `bson:"code"`
	Target           string                  `bson:"target"`
	Description      string                  `bson:"description"`
	ResponseTimeInMs int64                   `bson:"responseTimeInMs"`
	CreatedAt        time.Time               `bson:"createdAt"`
}

type HealthCheckRecordStatus

type HealthCheckRecordStatus string
const (
	HealthCheckRecordStatusUp   HealthCheckRecordStatus = "up"
	HealthCheckRecordStatusDown HealthCheckRecordStatus = "down"
)

type Monitor

type Monitor struct {
	ID        primitive.ObjectID `bson:"_id"`
	Owner     primitive.ObjectID `bson:"owner"` // main factor
	Code      string             `bson:"code"`
	Type      MonitorType        `bson:"type"`
	Target    string             `bson:"target"`
	Data      MonitorMetadata    `bson:"data"`
	Interval  int                `bson:"interval"`
	CreatedAt time.Time          `bson:"createdAt"`
}

type MonitorMetadata

type MonitorMetadata struct {
	Scheme string `bson:"scheme,omitempty"`
}

type MonitorType

type MonitorType string
const (
	MonitorTypeDomain MonitorType = "domain"
	MonitorTypeHTTP   MonitorType = "http"
	MonitorTypeTCP    MonitorType = "tcp"
	MonitorTypeICMP   MonitorType = "icmp"
)

type User

type User struct {
	ID        primitive.ObjectID             `bson:"_id"`
	Name      string                         `bson:"name"`
	Username  string                         `bson:"username"`
	Avatar    string                         `bson:"avatar"`
	Google    *UserSocialProviderInformation `bson:"google"`
	GitHub    *UserSocialProviderInformation `bson:"github"`
	Telegram  *UserPlatform                  `bson:"telegram"`
	Slack     *UserPlatform                  `bson:"slack"`
	Discord   *UserPlatform                  `bson:"discord"`
	CreatedAt time.Time                      `bson:"createdAt"`
}

type UserPlatform

type UserPlatform struct {
	UserID string `bson:"userId"`
	RoomID string `bson:"roomId"`
}

type UserSocialProviderInformation

type UserSocialProviderInformation struct {
	ID     string `bson:"id"`
	Name   string `bson:"name"`
	Email  string `bson:"email"`
	Avatar string `bson:"avatar"`
}

Jump to

Keyboard shortcuts

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