ark

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSuccessResponse

func IsSuccessResponse[T any](resp *GenericArkResponseBase[T]) error

IsSuccessResponse checks if the response is successful

Types

type ArkBizInfo

type ArkBizInfo struct {
	BizName        string `json:"bizName"`
	BizState       string `json:"bizState"`
	BizVersion     string `json:"bizVersion"`
	MainClass      string `json:"mainClass"`
	WebContextPath string `json:"webContextPath"`
}

ArkBizInfo is the response for querying all biz module in a given ark container.

type ArkContainerRunType

type ArkContainerRunType string
const (
	ArkContainerRunTypeLocal ArkContainerRunType = "local"
	ArkContainerRunTypeVM    ArkContainerRunType = "vm" // the reason why we need vm is we might use scp to copy file to vm server
	ArkContainerRunTypeK8s   ArkContainerRunType = "pod"
)

type ArkContainerRuntimeInfo

type ArkContainerRuntimeInfo struct {
	// RunType is the type of ark container, like local, vm server, pod, etc.
	RunType ArkContainerRunType `json:"runType"`

	// Coordinate is the exact location of ark container.
	// If the RunType is local, then it's localhost.
	// If the RunType is vm server, then it's ip.
	// If the RunType is pod, then it's the {namespace}/{podName}
	Coordinate string `json:"coordinate"`

	// Port is the ark api port of ark container.
	Port *int `json:"port"`
}

ArkContainerRuntimeInfo contains necessary info of an ark container.

func (*ArkContainerRuntimeInfo) GetPort

func (info *ArkContainerRuntimeInfo) GetPort() int

type ArkResponseBase

type ArkResponseBase struct {
	// Code is the response code
	Code string `json:"code"`

	// Data is the response data
	Data ArkResponseData `json:"data"`

	// Message is the error message
	Message string `json:"message"`

	// ErrorStackTrace is the error stack trace
	ErrorStackTrace string `json:"errorStackTrace"`
}

ArkResponseBase is the base response of ark api.

type ArkResponseData

type ArkResponseData struct {
	Code         string        `json:"code"`
	Message      string        `json:"message"`
	ElapsedSpace int           `json:"elapsedSpace"`
	BizInfos     []interface{} `json:"bizInfos"`
}

ArkResponseData is the response data of ark api.

type BizModel

type BizModel struct {
	// BizName the biz name
	BizName string `json:"bizName,omitempty"`

	// BizVersion is the version of biz module.
	BizVersion string `json:"bizVersion,omitempty"`

	// BizUrl is the location of source code.
	BizUrl fileutil.FileUrl `json:"bizUrl,omitempty"`
}

BizModel contains necessary metadata info of an ark biz. Usually this BizModel is generated automatically from bundle like jarfile.

func ParseBizModel

func ParseBizModel(ctx context.Context, bizUrl fileutil.FileUrl) (*BizModel, error)

ParseBizModel parse biz bundle given by bizUrl to BizModel.

type GenericArkResponseBase

type GenericArkResponseBase[T any] struct {
	// Code is the response code
	Code string `json:"code"`

	// Data is the response data
	Data T `json:"data"`

	// Message is the error message
	Message string `json:"message"`
}

GenericArkResponseBase is the base response of ark api.

type InstallBizRequest

type InstallBizRequest struct {
	// BizModel is the metadata a given biz module.
	BizModel BizModel `json:"bizModel"`

	// TargetContainer is the target ark container we want to install a biz module to.
	TargetContainer ArkContainerRuntimeInfo `json:"targetContainer"`

	// InstallType is the type of install.
	// If the InstallType is "filesystem", then it will install the local biz module.
	// If the InstallType is "http", then it will install the remote biz module.
	InstallType string `json:"installType"`

	// BizHomeDir is the location of all biz module.
	// If not given, we will use {tmp}/arkBiz/ dir instead.
	// This will only be used when install biz module from local filesystem.
	BizHomeDir *string `json:"bizHomeDir"`
}

InstallBizRequest is the request for installing biz module to ark container.

type InstallBizResponse

type InstallBizResponse struct {
	ArkResponseBase
}

InstallBizResponse is the response for installing biz module to ark container.

type QueryAllArkBizRequest

type QueryAllArkBizRequest struct {
	// HostName is where the ark container is running
	HostName string

	// Port is where the ark container is serving
	Port int
}

QueryAllArkBizRequest is the request for querying all biz module in a given ark container.

type QueryAllArkBizResponse

type QueryAllArkBizResponse struct {
	GenericArkResponseBase[[]ArkBizInfo]
}

QueryAllArkBizResponse is the response for querying all biz module in a given ark container.

type Service

type Service interface {
	// ParseBizModel parse the biz file and return the biz model.
	ParseBizModel(ctx context.Context, bizUrl fileutil.FileUrl) (*BizModel, error)

	// InstallBiz call the remote ark container to install biz.
	// The precondition is that the biz file is already uploaded to the ark container or file hosting service (e.g. oss).
	InstallBiz(ctx context.Context, req InstallBizRequest) error

	// UnInstallBiz call the remote ark container to install biz.
	// The precondition is that the biz file is already uploaded to the ark container or file hosting service (e.g. oss).
	UnInstallBiz(ctx context.Context, req UnInstallBizRequest) error

	// QueryAllBiz call the remote ark container to query biz.
	QueryAllBiz(ctx context.Context, req QueryAllArkBizRequest) (*QueryAllArkBizResponse, error)
}

Service is responsible for interacting with ark container.

func BuildService

func BuildService(_ context.Context) Service

BuildService return a new Service.

type UnInstallBizRequest

type UnInstallBizRequest struct {
	// BizModel is the metadata a given biz module.
	BizModel BizModel `json:"bizModel"`

	// TargetContainer is the target ark container we want to install a biz module to.
	TargetContainer ArkContainerRuntimeInfo `json:"targetContainer"`
}

UnInstallBizRequest is the request for installing biz module to ark container.

type UnInstallBizResponse

type UnInstallBizResponse struct {
	ArkResponseBase
}

UnInstallBizResponse is the response for installing biz module to ark container.

Jump to

Keyboard shortcuts

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