database

package
v0.0.0-...-0d12cdc Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionName = "pterodactyl_matchinfo"
	DatabaseName   = "unwindia"
	DefaultTimeout = 10 * time.Second
)

Variables

View Source
var ActionName = map[int]string{
	0: "create",
	1: "delete",
}
View Source
var JobStatusName = map[int]string{
	0: "new",
	1: "inProgress",
	2: "finished",
	3: "error",
}

Functions

This section is empty.

Types

type Action

type Action int
const (
	ActionCreate Action = iota
	ActionDelete
)

func (Action) String

func (m Action) String() string

func (*Action) UnmarshalJSON

func (m *Action) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals b into MessageTypes.

type DatabaseClient

type DatabaseClient interface {
	// UpsertJob creates or updates an DotlanForumStatus entry
	CreateJob(ctx context.Context, entry *Job) (primitive.ObjectID, error)
	UpdateJob(ctx context.Context, entry *Job) (primitive.ObjectID, error)
	UpsertMatchInfo(ctx context.Context, entry *MatchInfo) error
	// Get returns an existing DotlanForumStatus by the given id. Id is the id of the match within dotlan (tcontest.tcid)
	GetJob(ctx context.Context, id string) (*Job, error)
	// List returns all existing DotlanForumStatus entries in a Result chan
	//List(ctx context.Context, filter interface{}, resultChan chan Result)
	List(ctx context.Context, filter interface{}) ([]*Job, error)
	GetMatchInfo(ctx context.Context, id string) (*MatchInfo, error)
}

DatabaseClient is the client-interface for the main mongodb database

type DatabaseClientImpl

type DatabaseClientImpl struct {
	// contains filtered or unexported fields
}

func (DatabaseClientImpl) CreateJob

func (d DatabaseClientImpl) CreateJob(ctx context.Context, entry *Job) (primitive.ObjectID, error)

func (DatabaseClientImpl) GetJob

func (d DatabaseClientImpl) GetJob(ctx context.Context, id string) (*Job, error)

func (DatabaseClientImpl) GetMatchInfo

func (d DatabaseClientImpl) GetMatchInfo(ctx context.Context, id string) (*MatchInfo, error)

func (DatabaseClientImpl) List

func (d DatabaseClientImpl) List(ctx context.Context, filter interface{}) ([]*Job, error)

func (d DatabaseClientImpl) List(ctx context.Context, filter interface{}, resultChan chan Result) {

func (DatabaseClientImpl) UpdateJob

func (d DatabaseClientImpl) UpdateJob(ctx context.Context, entry *Job) (primitive.ObjectID, error)

func (DatabaseClientImpl) UpsertMatchInfo

func (d DatabaseClientImpl) UpsertMatchInfo(ctx context.Context, entry *MatchInfo) error

type Job

type Job struct {
	mgm.DefaultModel `bson:",inline"`
	Action           Action
	Status           JobStatus
	MatchId          string
	Game             string
	Slots            int
	ServerId         int
	ExecAfter        *time.Time `bson:"execAfter,omitempty"`
	MatchInfo        matchservice.MatchInfo
}

func (*Job) CollectionName

func (*Job) CollectionName() string

type JobStatus

type JobStatus int
const (
	JobStatusNew JobStatus = iota
	JobStatusInProgress
	JobStatusFinished
	JobStatusError
)

func (JobStatus) String

func (m JobStatus) String() string

func (*JobStatus) UnmarshalJSON

func (m *JobStatus) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals b into MessageTypes.

type MatchInfo

type MatchInfo struct {
	Id        string                 `bson:"_id" json:"id"`
	MatchInfo matchservice.MatchInfo `bson:"matchInfo,omitempty"`
	JobIds    []primitive.ObjectID   `json:"jobId" bson:"jobIds,omitempty"`
	CreatedAt time.Time              `bson:"createdAt,omitempty"`
	UpdatedAt time.Time              `bson:"updatedAt,omitempty"`
}

func (*MatchInfo) CollectionName

func (*MatchInfo) CollectionName() string

type ServerStatus

type ServerStatus struct {
	mgm.DefaultModel   `bson:",inline"`
	MatchId            string `json:"matchId" bson:"matchId,omitempty"`
	ServerId           string `json:"serverId" bson:"serverId,omitempty"`
	ServerName         string
	ServerIp           string
	ServerPort         int
	ServerPassword     string
	ServerMgmtPassword string
}

func (*ServerStatus) CollectionName

func (*ServerStatus) CollectionName() string

Jump to

Keyboard shortcuts

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