proto

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

databeat v0.1.0 05b62e4c87147149adb52dd13fe2de8c53a3c72f -- Code generated by webrpc-gen@v0.14.0-dev with golang generator. DO NOT EDIT.

webrpc-gen -schema=databeat.ridl -target=golang -pkg=proto -client -out=./clients/databeat.gen.go

Index

Constants

View Source
const DatabeatAdminPathPrefix = "/rpc/DatabeatAdmin/"
View Source
const DatabeatPathPrefix = "/rpc/Databeat/"
View Source
const DatabeatQueryPathPrefix = "/rpc/DatabeatQuery/"

Variables

View Source
var (
	HTTPClientRequestHeadersCtxKey = &contextKey{"HTTPClientRequestHeaders"}
	HTTPRequestCtxKey              = &contextKey{"HTTPRequest"}

	ServiceNameCtxKey = &contextKey{"ServiceName"}

	MethodNameCtxKey = &contextKey{"MethodName"}
)
View Source
var (
	ErrWebrpcEndpoint      = WebRPCError{Code: 0, Name: "WebrpcEndpoint", Message: "endpoint error", HTTPStatus: 400}
	ErrWebrpcRequestFailed = WebRPCError{Code: -1, Name: "WebrpcRequestFailed", Message: "request failed", HTTPStatus: 400}
	ErrWebrpcBadRoute      = WebRPCError{Code: -2, Name: "WebrpcBadRoute", Message: "bad route", HTTPStatus: 404}
	ErrWebrpcBadMethod     = WebRPCError{Code: -3, Name: "WebrpcBadMethod", Message: "bad method", HTTPStatus: 405}
	ErrWebrpcBadRequest    = WebRPCError{Code: -4, Name: "WebrpcBadRequest", Message: "bad request", HTTPStatus: 400}
	ErrWebrpcBadResponse   = WebRPCError{Code: -5, Name: "WebrpcBadResponse", Message: "bad response", HTTPStatus: 500}
	ErrWebrpcServerPanic   = WebRPCError{Code: -6, Name: "WebrpcServerPanic", Message: "server panic", HTTPStatus: 500}
	ErrWebrpcInternalError = WebRPCError{Code: -7, Name: "WebrpcInternalError", Message: "internal error", HTTPStatus: 500}
)

Webrpc errors

View Source
var (
	ErrUnauthorized     = WebRPCError{Code: 1000, Name: "Unauthorized", Message: "Unauthorized access", HTTPStatus: 401}
	ErrPermissionDenied = WebRPCError{Code: 2000, Name: "PermissionDenied", Message: "Permission denied", HTTPStatus: 403}
	ErrSessionExpired   = WebRPCError{Code: 2001, Name: "SessionExpired", Message: "Session expired", HTTPStatus: 403}
	ErrNotFound         = WebRPCError{Code: 3000, Name: "NotFound", Message: "Resource not found", HTTPStatus: 404}
	ErrInvalidAppKey    = WebRPCError{Code: 4000, Name: "InvalidAppKey", Message: "Invalid app key", HTTPStatus: 400}
	ErrQueryFailed      = WebRPCError{Code: 4001, Name: "QueryFailed", Message: "DB query failed", HTTPStatus: 400}
)

Schema errors

View Source
var EventType_name = map[uint32]string{
	0: "INIT",
	1: "VIEW",
	2: "REQUEST",
}
View Source
var EventType_value = map[string]uint32{
	"INIT":    0,
	"VIEW":    1,
	"REQUEST": 2,
}
View Source
var Ident_name = map[uint8]string{
	0: "ANONYMOUS",
	1: "PRIVATE",
	2: "USER",
	3: "SERVICE",
}
View Source
var Ident_value = map[string]uint8{
	"ANONYMOUS": 0,
	"PRIVATE":   1,
	"USER":      2,
	"SERVICE":   3,
}
View Source
var WebRPCServices = map[string][]string{
	"Databeat": {
		"Ping",
		"Version",
		"RuntimeStatus",
		"Tick",
		"RawEvents",
	},
	"DatabeatAdmin": {
		"ListApps",
		"CreateApp",
		"GetApp",
		"UpdateApp",
		"DisableApp",
	},
	"DatabeatQuery": {
		"QueryDateRange",
	},
}

Functions

func HTTPRequestHeaders

func HTTPRequestHeaders(ctx context.Context) (http.Header, bool)

func MethodNameFromContext added in v0.6.0

func MethodNameFromContext(ctx context.Context) string

func RequestFromContext added in v0.6.0

func RequestFromContext(ctx context.Context) *http.Request

func ServiceNameFromContext added in v0.6.0

func ServiceNameFromContext(ctx context.Context) string

func WebRPCSchemaHash

func WebRPCSchemaHash() string

Schema hash generated from your RIDL schema

func WebRPCSchemaVersion

func WebRPCSchemaVersion() string

Schema version of your RIDL schema

func WebRPCVersion

func WebRPCVersion() string

WebRPC description and code-gen version

func WithHTTPRequestHeaders

func WithHTTPRequestHeaders(ctx context.Context, h http.Header) (context.Context, error)

Types

type App

type App struct {
	UID      string   `json:"uid" ch:"uid"`
	Name     string   `json:"name" ch:"name"`
	Domains  []string `json:"domains" ch:"domains"`
	Disabled bool     `json:"disabled" ch:"disabled"`
}

type Databeat

type Databeat interface {
	Ping(ctx context.Context) (bool, error)
	Version(ctx context.Context) (*Version, error)
	RuntimeStatus(ctx context.Context) (*RuntimeStatus, error)
	Tick(ctx context.Context, events []*Event) (bool, error)
	RawEvents(ctx context.Context, events []*RawEvent) (bool, error)
}

func NewDatabeatClient

func NewDatabeatClient(addr string, client HTTPClient) Databeat

type DatabeatAdmin added in v0.3.0

type DatabeatAdmin interface {
	ListApps(ctx context.Context) ([]*App, error)
	CreateApp(ctx context.Context, uid string, name string, domains []string) (*App, error)
	GetApp(ctx context.Context, appUid string) (*App, error)
	UpdateApp(ctx context.Context, app *App) (bool, error)
	DisableApp(ctx context.Context, appUid string, disabled bool) (bool, error)
}

func NewDatabeatAdminClient added in v0.3.0

func NewDatabeatAdminClient(addr string, client HTTPClient) DatabeatAdmin

type DatabeatQuery added in v0.3.0

type DatabeatQuery interface {
	QueryDateRange(ctx context.Context, appUid string, event string, from time.Time, to time.Time) (interface{}, error)
}

func NewDatabeatQueryClient added in v0.3.0

func NewDatabeatQueryClient(addr string, client HTTPClient) DatabeatQuery

type Device

type Device struct {
	Type           string `json:"type"`
	OS             string `json:"os"`
	OSVersion      string `json:"osVersion"`
	Browser        string `json:"browser"`
	BrowserVersion string `json:"browserVersion"`
}

type Event

type Event struct {
	Event       string                 `json:"event"`
	ProjectID   uint64                 `json:"projectId"`
	Source      string                 `json:"source"`
	Ident       uint8                  `json:"ident"`
	UserID      *string                `json:"userId"`
	SessionID   *string                `json:"sessionId"`
	Device      *Device                `json:"device"`
	CountryCode *string                `json:"countryCode"`
	Props       map[string]string      `json:"props"`
	Nums        map[string]float64     `json:"nums"`
	Etc         map[string]interface{} `json:"-" ch:"-"`
}

type EventType added in v0.2.0

type EventType uint32
const (
	EventType_INIT    EventType = 0
	EventType_VIEW    EventType = 1
	EventType_REQUEST EventType = 2
)

func (EventType) MarshalText added in v0.6.0

func (x EventType) MarshalText() ([]byte, error)

func (EventType) String added in v0.2.0

func (x EventType) String() string

func (*EventType) UnmarshalText added in v0.6.0

func (x *EventType) UnmarshalText(b []byte) error

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.

type Ident added in v0.6.0

type Ident uint8
const (
	Ident_ANONYMOUS Ident = 0
	Ident_PRIVATE   Ident = 1
	Ident_USER      Ident = 2
	Ident_SERVICE   Ident = 3
)

func (Ident) MarshalText added in v0.6.0

func (x Ident) MarshalText() ([]byte, error)

func (Ident) String added in v0.6.0

func (x Ident) String() string

func (*Ident) UnmarshalText added in v0.6.0

func (x *Ident) UnmarshalText(b []byte) error

type RawEvent added in v0.2.0

type RawEvent struct {
	App                  *string                `json:"app" ch:"app"`
	TS                   *time.Time             `json:"ts" ch:"ts"`
	Event                string                 `json:"event" ch:"event"`
	ProjectID            uint64                 `json:"projectId" ch:"project_id"`
	Source               string                 `json:"source" ch:"source"`
	Ident                uint8                  `json:"ident" ch:"ident"`
	UserID               *string                `json:"userId" ch:"user_id"`
	SessionID            *string                `json:"sessionId" ch:"session_id"`
	CountryCode          *string                `json:"countryCode" ch:"country"`
	DeviceType           *string                `json:"deviceType" ch:"device_type"`
	DeviceOS             *string                `json:"deviceOs" ch:"device_os"`
	DeviceOSVersion      *string                `json:"deviceOsVersion" ch:"device_os_ver"`
	DeviceBrowser        *string                `json:"deviceBrowser" ch:"device_browser"`
	DeviceBrowserVersion *string                `json:"deviceBrowserVersion" ch:"device_browser_ver"`
	Props                map[string]string      `json:"props" ch:"props"`
	Nums                 map[string]float64     `json:"nums" ch:"nums"`
	Etc                  map[string]interface{} `json:"-" ch:"-"`
}

type RuntimeStatus

type RuntimeStatus struct {
	HealthOK      bool                   `json:"healthOK"`
	StartTime     time.Time              `json:"startTime"`
	Uptime        uint64                 `json:"uptime"`
	Ver           string                 `json:"ver"`
	Branch        string                 `json:"branch"`
	CommitHash    string                 `json:"commitHash"`
	SinkStats     *SinkStats             `json:"sinkStats"`
	PipelineStats map[string]interface{} `json:"pipelineStats"`
	GcpPubSub     bool                   `json:"gcpPubSub"`
}

type SinkStats added in v0.3.0

type SinkStats struct {
	NumEvents uint64 `json:"numEvents"`
	NumFails  uint64 `json:"numFails"`
}

type Version

type Version struct {
	WebrpcVersion string `json:"webrpcVersion"`
	SchemaVersion string `json:"schemaVersion"`
	SchemaHash    string `json:"schemaHash"`
	AppVersion    string `json:"appVersion"`
}

type WebRPCError added in v0.3.0

type WebRPCError struct {
	Name       string `json:"error"`
	Code       int    `json:"code"`
	Message    string `json:"msg"`
	Cause      string `json:"cause,omitempty"`
	HTTPStatus int    `json:"status"`
	// contains filtered or unexported fields
}

func ErrorWithCause deprecated added in v0.3.0

func ErrorWithCause(rpcErr WebRPCError, cause error) WebRPCError

Deprecated: Use .WithCause() method on WebRPCError.

func (WebRPCError) Error added in v0.3.0

func (e WebRPCError) Error() string

func (WebRPCError) Is added in v0.3.0

func (e WebRPCError) Is(target error) bool

func (WebRPCError) Unwrap added in v0.3.0

func (e WebRPCError) Unwrap() error

func (WebRPCError) WithCause added in v0.6.0

func (e WebRPCError) WithCause(cause error) WebRPCError

Jump to

Keyboard shortcuts

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