Documentation
¶
Index ¶
- Constants
- Variables
- func IsErrUpstreamRpcReturnedError(err error) bool
- func ParseJsonRpcResponse[T any](bz []byte) (any, error)
- func WrapAppContext(ctx Context) context.Context
- type Context
- func (c Context) Deadline() (deadline time.Time, ok bool)
- func (c Context) Done() <-chan struct{}
- func (c Context) Err() error
- func (c Context) GetOperationUserInfo() *OperationUserInfo
- func (c Context) GetWorkingUserInfo() *UserInfo
- func (c Context) Value(key any) any
- func (c Context) WithContext(ctx context.Context) Context
- func (c Context) WithWorkingUserInfo(workingUserInfo *UserInfo) Context
- type ContextKey
- type JsonRpcQueryBuilder
- type JsonRpcQueryParam
- func NewJsonRpcBoolQueryParam(value bool) JsonRpcQueryParam
- func NewJsonRpcInt64QueryParam(num int64) JsonRpcQueryParam
- func NewJsonRpcIntQueryParam(num int) JsonRpcQueryParam
- func NewJsonRpcRawQueryParam(rawStr string) JsonRpcQueryParam
- func NewJsonRpcStringArrayQueryParam(strArr ...string) (JsonRpcQueryParam, error)
- func NewJsonRpcStringQueryParam(str string) (JsonRpcQueryParam, error)
- type OperationUserInfo
- type UserInfo
Constants ¶
View Source
const AppContextKey = constants.BINARY_NAME + "-app-context"
AppContextKey is the key in the context.Context which holds the application context.
Variables ¶
View Source
var ErrUpstreamRpcReturnedError = errors.New("upstream RPC returned error")
ErrUpstreamRpcReturnedError is the error when the upstream RPC returned error
Functions ¶
func IsErrUpstreamRpcReturnedError ¶
IsErrUpstreamRpcReturnedError returns true if the error is built from upstream RPC response error, when error code is not zero.
func WrapAppContext ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext(operationUserInfo *OperationUserInfo) Context
func UnwrapAppContext ¶
func (Context) GetOperationUserInfo ¶
func (c Context) GetOperationUserInfo() *OperationUserInfo
func (Context) GetWorkingUserInfo ¶
func (Context) WithWorkingUserInfo ¶
type JsonRpcQueryBuilder ¶
type JsonRpcQueryBuilder interface {
String() string
}
func NewJsonRpcQueryBuilder ¶
func NewJsonRpcQueryBuilder( method string, params ...JsonRpcQueryParam, ) JsonRpcQueryBuilder
type JsonRpcQueryParam ¶
type JsonRpcQueryParam interface { // IsArray returns true if the param is array formed IsArray() bool // String returns string of the param String() string }
func NewJsonRpcBoolQueryParam ¶
func NewJsonRpcBoolQueryParam(value bool) JsonRpcQueryParam
func NewJsonRpcInt64QueryParam ¶
func NewJsonRpcInt64QueryParam(num int64) JsonRpcQueryParam
func NewJsonRpcIntQueryParam ¶
func NewJsonRpcIntQueryParam(num int) JsonRpcQueryParam
func NewJsonRpcRawQueryParam ¶
func NewJsonRpcRawQueryParam(rawStr string) JsonRpcQueryParam
func NewJsonRpcStringArrayQueryParam ¶
func NewJsonRpcStringArrayQueryParam(strArr ...string) (JsonRpcQueryParam, error)
func NewJsonRpcStringQueryParam ¶
func NewJsonRpcStringQueryParam(str string) (JsonRpcQueryParam, error)
type OperationUserInfo ¶
type OperationUserInfo struct { EffectiveUserInfo *UserInfo RealUserInfo *UserInfo // IsSameUser indicate that operation user is the same as real user IsSameUser bool // IsSuperUser indicate that operation user is "root" or a user that belong to a super-user group IsSuperUser bool // OperatingAsSuperUser indicates that operation user is "root" or a user runs command with "sudo" OperatingAsSuperUser bool }
func (*OperationUserInfo) GetDefaultWorkingUser ¶
func (o *OperationUserInfo) GetDefaultWorkingUser() *UserInfo
GetDefaultWorkingUser returns:
- Effective user if is not super-user and not operating as super-user
- Real user otherwise
func (*OperationUserInfo) RequireOperatingAsNonSuperUser ¶
func (o *OperationUserInfo) RequireOperatingAsNonSuperUser()
func (*OperationUserInfo) RequireOperatingAsSuperUser ¶
func (o *OperationUserInfo) RequireOperatingAsSuperUser()
func (*OperationUserInfo) RequireSuperUser ¶
func (o *OperationUserInfo) RequireSuperUser()
Click to show internal directories.
Click to hide internal directories.