dashcloud

package
Version: v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TlsKeyFileName         = "dashborg-client.key"
	TlsCertFileName        = "dashborg-client.crt"
	DefaultProcName        = "default"
	DefaultZoneName        = "default"
	DefaultPanelName       = "default"
	DefaultLocalServerAddr = "localhost:8082"
	DefaultConsoleHost     = "console.dashborg.net"
	DefaultProcHost        = "grpc.api.dashborg.net"
)

Variables

View Source
var NotConnectedErr = dasherr.ErrWithCodeStr(dasherr.ErrCodeNotConnected, "DashborgCloudClient is not Connected")

Functions

This section is empty.

Types

type AppStruct

type AppStruct struct {
	AppClient dash.AppClient
	App       dash.AppRuntime
}

type Config

type Config struct {
	// DASHBORG_ACCID, set to force an AccountId (must match certificate).  If not set, AccountId is set from certificate file.
	// If AccId is given and AutoKeygen is true, and key/cert files are not found, Dashborg will create a new self-signed
	//     keypair using the AccId given.
	// If AccId is given, and the certificate does not match, this will cause a panic.
	AccId string

	// Set to true for unregistered/unclaimed accounts
	AnonAcc bool

	// DASHBORG_ZONE defaults to "default"
	ZoneName string

	// Process Name Attributes.  Only ProcName is required
	ProcName string // DASHBORG_PROCNAME (set from executable filename if not set)
	ProcTags map[string]string

	KeyFileName  string // DASHBORG_KEYFILE private key file (defaults to dashborg-client.key)
	CertFileName string // DASHBORG_CERTFILE certificate file, CN must be set to your Dashborg Account Id.  (defaults to dashborg-client.crt)

	// Create a self-signed key/cert if they do not exist.  This will also create a random Account Id.
	// Should only be used with AnonAcc is true.  If AccId is set, will create a key with that AccId
	AutoKeygen bool

	// DASHBORG_VERBOSE, set to true for extra debugging information
	Verbose bool

	// close this channel to force a shutdown of the Dashborg Cloud Client
	ShutdownCh chan struct{}

	// These are for internal testing, should not normally be set by clients.
	Env                 string // DASHBORG_ENV
	DashborgSrvHost     string // DASHBORG_PROCHOST
	DashborgSrvPort     int    // DASHBORG_PROCPORT
	DashborgConsoleHost string // DASHBORG_CONSOLEHOST

	NoShowJWT   bool          // set to true to disable showing app-link with jwt param
	JWTDuration time.Duration // defaults to 24*time.Hour
	JWTUserId   string        // defaults to "jwt-user"
	JWTRole     string        // defaults to "user"

	Logger *log.Logger // use to override the SDK's logger object
	// contains filtered or unexported fields
}

func (*Config) MakeAccountJWT

func (c *Config) MakeAccountJWT(validFor time.Duration, id string, role string) (string, error)

Creates a JWT token from the public/private keypair

func (*Config) MustMakeAccountJWT

func (c *Config) MustMakeAccountJWT(validFor time.Duration, id string, role string) string

type DashCloudClient

type DashCloudClient struct {
	Lock      *sync.Mutex
	StartTime time.Time
	ProcRunId string
	Config    *Config
	Conn      *grpc.ClientConn
	DBService dashproto.DashborgServiceClient
	ConnId    *atomic.Value
	AppMap    map[string]*AppStruct
	DoneCh    chan bool
	PermErr   bool
	ExitErr   error
	AccInfo   accInfoType
}

func MakeClient

func MakeClient(config *Config) (*DashCloudClient, error)

func (*DashCloudClient) ConnectApp

func (pc *DashCloudClient) ConnectApp(app *dash.App) error

func (*DashCloudClient) ConnectAppRuntime

func (pc *DashCloudClient) ConnectAppRuntime(app dash.AppRuntime) error

func (*DashCloudClient) GetExitError

func (pc *DashCloudClient) GetExitError() error

Returns nil if client is still running. Returns error (reason for shutdown) if client has stopped.

func (*DashCloudClient) InternalApi

func (pc *DashCloudClient) InternalApi() *InternalApi

func (*DashCloudClient) IsConnected

func (pc *DashCloudClient) IsConnected() bool
func (pc *DashCloudClient) MakeJWTAppLink(appName string, validTime time.Duration, userId string, roleName string) (string, error)
func (pc *DashCloudClient) MustMakeJWTAppLink(appName string, validTime time.Duration, userId string, roleName string) string

func (*DashCloudClient) OpenApp

func (pc *DashCloudClient) OpenApp(appName string) (*dash.App, error)

func (*DashCloudClient) ReflectZone

func (pc *DashCloudClient) ReflectZone() (*ReflectZoneType, error)

func (*DashCloudClient) RemoveApp

func (pc *DashCloudClient) RemoveApp(appName string) error

func (*DashCloudClient) WaitForShutdown

func (pc *DashCloudClient) WaitForShutdown() error

returns the reason for shutdown (GetExitError())

func (*DashCloudClient) WriteApp

func (pc *DashCloudClient) WriteApp(app *dash.App) error

type InternalApi

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

Used for low-level communication between AppClient and the Dashborg Cloud Service. Not for use by general SDK users. API not stable and subject to change

func (*InternalApi) BackendPush

func (rpc *InternalApi) BackendPush(appName string, path string, data interface{}) error

func (*InternalApi) CallDataHandler

func (rpc *InternalApi) CallDataHandler(appName string, path string, data interface{}) (interface{}, error)

func (*InternalApi) ListBlobs

func (rpc *InternalApi) ListBlobs(appName string, appVersion string) ([]dash.BlobData, error)

func (*InternalApi) RemoveBlob

func (rpc *InternalApi) RemoveBlob(acfg dash.AppConfig, blob dash.BlobData) error

func (*InternalApi) SendResponseProtoRpc

func (rpc *InternalApi) SendResponseProtoRpc(m *dashproto.SendResponseMessage) (int, error)

SendResponseProtoRpc is for internal use by the Dashborg AppClient, not to be called by the end user.

func (*InternalApi) SetBlobData

func (rpc *InternalApi) SetBlobData(acfg dash.AppConfig, blobData dash.BlobData, r io.Reader) error

func (*InternalApi) StartBareStream

func (rpc *InternalApi) StartBareStream(appName string, streamOpts dash.StreamOpts) (*dash.Request, error)

func (*InternalApi) StartStreamProtoRpc

func (rpc *InternalApi) StartStreamProtoRpc(m *dashproto.StartStreamMessage) (string, error)

type ReflectAppType

type ReflectAppType struct {
	AppName    string   `json:"appname"`
	ProcRunIds []string `json:"procrunids"`
}

type ReflectProcType

type ReflectProcType struct {
	StartTs   int64             `json:"startts"`
	ProcName  string            `json:"procname"`
	ProcTags  map[string]string `json:"proctags"`
	ProcRunId string            `json:"procrunid"`
}

type ReflectZoneType

type ReflectZoneType struct {
	AccId    string                     `json:"accid"`
	ZoneName string                     `json:"zonename"`
	Procs    map[string]ReflectProcType `json:"procs"`
	Apps     map[string]ReflectAppType  `json:"apps"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL