Documentation
¶
Index ¶
- Constants
- Variables
- func Ping(ctx context.Context, api ajt.Api) *mft.Error
- func PingAsUser(ctx context.Context, api ajt.Api, user string) *mft.Error
- type Api
- func (api *Api) AddApi(a ajt.Api)
- func (api *Api) AddAuthenticationChecker(ac authentication.AuthenticationChecker)
- func (api *Api) Do(ctx context.Context, compType compress.CompressionType, bodyRequest []byte) (outCompType compress.CompressionType, bodyResponce []byte)
- func (api *Api) MarshalResponce(ctx context.Context, compType compress.CompressionType, resp *Responce) (outCompType compress.CompressionType, bodyResponce []byte)
- func (api *Api) RLock(ctx context.Context) bool
- func (api *Api) RUnlock()
- type ApiProvider
- func (sa *ApiProvider) AllowedCommands() []ajt.CommandDescription
- func (ap *ApiProvider) DoRequest(ctx context.Context, reqCmd *ajt.CommandRequest) *ajt.CommandResponce
- func (api *ApiProvider) RLock(ctx context.Context) bool
- func (api *ApiProvider) RUnlock()
- func (api *ApiProvider) UpdatePreferCompressLast(preferCompressLast []compress.CompressionType)
- type CallFunction
- type GetCompressionFunc
- type Request
- type Responce
- type ServiceApi
Constants ¶
View Source
const ( ServiceApiObjectType ajt.ObjectType = "service_api" PingAction ajt.Action = "ping" )
Variables ¶
View Source
var Errors map[int]string = map[int]string{
20400000: "api_json.Request.Marchal: fail to marshal",
20400010: "api_json.Request.Unmarchal: fail to unmarshal",
20400020: "api_json.Responce.Marchal: fail to marshal",
20400030: "api_json.Responce.Unmarchal: fail to unmarshal",
20400040: "api_json.Api.MarshalResponce: fail to compress compress type `%v`",
20400050: "api_json.Api.Do: R lock fail",
20400051: "api_json.Api.Do: Unknown object type `%v`",
20400052: "api_json.Api.Do: Unknown action `%v`",
20400053: "api_json.Api.Do: api not init",
20400054: "api_json.Api.Do: authentication type not allowed `%v`",
20400055: "api_json.Api.Do: authentication internal error for user `%v`",
20400056: "api_json.Api.Do: authentication fail for user `%v`",
20400057: "api_json.Api.Do: impersonate for user `%v` as `%v` internal error",
20400058: "api_json.Api.Do: impersonate for user `%v` as `%v` fail",
20400059: "api_json.Api.Do: fail to restore compress type `%v`",
20400060: "api_json.Api.Do: fail to unmarshal request (compress type `%v`)",
20400200: "api_json.ApiProvider.DoRequest: R lock fail",
20400201: "api_json.ApiProvider.DoRequest: fail to compress; compress type `%v`",
20400202: "api_json.ApiProvider.DoRequest: fail to restore; compress type `%v`",
20400203: "api_json.ApiProvider.DoRequest: unmarshal responce fail",
20400204: "api_json.ApiProvider.DoRequest: fail to call CallFunc; object type `%v` action `%v`",
20400400: "api_json.ServiceApi.DoRequest: Unknown object type `%v` action `%v`",
}
Errors codes and description
Functions ¶
Types ¶
type Api ¶
type Api struct {
Compressor *compress.Generator
ApisMap map[ajt.ObjectType]map[ajt.Action]ajt.Api
GetCompression GetCompressionFunc
AuthenticationChecker map[string]authentication.AuthenticationChecker
PermissionChecker authorization.PermissionChecker
// contains filtered or unexported fields
}
func (*Api) AddAuthenticationChecker ¶ added in v0.0.1
func (api *Api) AddAuthenticationChecker(ac authentication.AuthenticationChecker)
func (*Api) Do ¶
func (api *Api) Do(ctx context.Context, compType compress.CompressionType, bodyRequest []byte, ) (outCompType compress.CompressionType, bodyResponce []byte)
func (*Api) MarshalResponce ¶
func (api *Api) MarshalResponce(ctx context.Context, compType compress.CompressionType, resp *Responce, ) (outCompType compress.CompressionType, bodyResponce []byte)
type ApiProvider ¶
type ApiProvider struct {
Compressor *compress.Generator
CallFunc CallFunction
GetCompression GetCompressionFunc
PreferCompressLastResponce []compress.CompressionType
AuthType string
UserNameRequest string
SecretInfo json.RawMessage
// contains filtered or unexported fields
}
func (*ApiProvider) AllowedCommands ¶
func (sa *ApiProvider) AllowedCommands() []ajt.CommandDescription
func (*ApiProvider) DoRequest ¶
func (ap *ApiProvider) DoRequest(ctx context.Context, reqCmd *ajt.CommandRequest) *ajt.CommandResponce
func (*ApiProvider) RUnlock ¶
func (api *ApiProvider) RUnlock()
func (*ApiProvider) UpdatePreferCompressLast ¶
func (api *ApiProvider) UpdatePreferCompressLast(preferCompressLast []compress.CompressionType)
type CallFunction ¶
type GetCompressionFunc ¶
type GetCompressionFunc func(preferCompress []compress.CompressionType, ) (outCompType compress.CompressionType, outPreferCompress []compress.CompressionType)
var ZipCompressFunc GetCompressionFunc = func(preferCompress []compress.CompressionType, ) (outCompType compress.CompressionType, outPreferCompress []compress.CompressionType) { if len(preferCompress) != 0 { ze := false for _, ct := range preferCompress { if ct == compress.Zip || ct == compress.Zip1 || ct == compress.Zip9 { ze = true } } if !ze { outCompType = compress.NoCompression outPreferCompress = zipOutPreferCompress } } outCompType = compress.Zip outPreferCompress = zipOutPreferCompress return outCompType, outPreferCompress }
type Request ¶
type Request struct {
UserNameRequest string `json:"user_name,omitempty"`
SecretInfo json.RawMessage `json:"secret_info,omitempty"`
AuthType string `json:"auth_type,omitempty"`
CommandRequest ajt.CommandRequest `json:"request,omitempty"`
PreferCompress []compress.CompressionType `json:"prefer_compress,omitempty"`
}
func (*Request) Marchal ¶
func (r *Request) Marchal() json.RawMessage
type Responce ¶
type Responce struct {
CommandResponce ajt.CommandResponce `json:"responce,omitempty"`
PreferCompress []compress.CompressionType `json:"prefer_compress,omitempty"`
}
func (*Responce) Marchal ¶
func (r *Responce) Marchal() json.RawMessage
type ServiceApi ¶
type ServiceApi struct {
}
func (*ServiceApi) AllowedCommands ¶
func (sa *ServiceApi) AllowedCommands() []ajt.CommandDescription
func (*ServiceApi) DoRequest ¶
func (sa *ServiceApi) DoRequest(ctx context.Context, req *ajt.CommandRequest) *ajt.CommandResponce
Click to show internal directories.
Click to hide internal directories.