Documentation
¶
Index ¶
- Constants
- func CallSentTasksFabric() *sentTasksHandler
- type AgentResult
- type ByteCase
- type CasesHandler
- type CommonExpression
- type CommonTask
- type CommonTasksHandler
- type CommonUser
- type DbUser
- func (d *DbUser) GetHashedPassword() string
- func (d *DbUser) GetId() int64
- func (d *DbUser) GetLogin() string
- func (d *DbUser) Is(user UserWithPassword) (status bool)
- func (d *DbUser) SetHashedPassword(salt string) (err error)
- func (d *DbUser) SetId(newId int64)
- func (d *DbUser) SetLogin(login string)
- type EmptyJson
- type EnvVar
- type ExprStatus
- type Expression
- func (e *Expression) DivideIntoTasks()
- func (e *Expression) GetId() int
- func (e *Expression) GetOwnerId() int64
- func (e *Expression) GetReadyGrpcTask() (result GrpcTask, err error)
- func (e *Expression) GetResult() int64
- func (e *Expression) GetStatus() ExprStatus
- func (e *Expression) GetTasksHandler() CommonTasksHandler
- func (e *Expression) Marshal() (result []byte, err error)
- func (e *Expression) MarshalId() (result []byte, err error)
- func (e *Expression) MarshalJSON() (result []byte, err error)
- func (e *Expression) UpdateTask(result GrpcResult, timeAtReceiveTask time.Time) (err error)
- type ExpressionJsonStub
- type ExpressionJsonTitle
- type ExpressionJsonTitleStub
- type ExpressionStub
- func (s *ExpressionStub) DivideIntoTasks()
- func (s *ExpressionStub) GetId() int
- func (s *ExpressionStub) GetOwnerId() int64
- func (s *ExpressionStub) GetReadyGrpcTask() (GrpcTask, error)
- func (s *ExpressionStub) GetResult() int64
- func (s *ExpressionStub) GetStatus() ExprStatus
- func (s *ExpressionStub) GetTasksHandler() CommonTasksHandler
- func (s *ExpressionStub) Marshal() (result []byte, err error)
- func (s *ExpressionStub) MarshalId() (result []byte, err error)
- func (s *ExpressionStub) UpdateTask(result GrpcResult, _ time.Time) (err error)
- type ExpressionsJsonTitle
- type ExpressionsJsonTitleStub
- type GrpcResult
- type GrpcTask
- type HashMan
- type HttpCasesHandler
- type InternalTask
- type JsonPayload
- type JsonUser
- type JwtTokenJsonWrapperStub
- type NoReadyTask
- type OneReadyTaskBug
- type PairIdHolder
- type RequestJsonStub
- type ResultHolder
- type ServerMuxHttpCasesHandler
- type ShortExpression
- type Task
- func (t *Task) GetArg1() (int64, bool)
- func (t *Task) GetArg2() (int64, bool)
- func (t *Task) GetOperation() string
- func (t *Task) GetPairId() int32
- func (t *Task) GetPermissibleDuration() time.Duration
- func (t *Task) GetResult() int64
- func (t *Task) GetStatus() TaskStatus
- func (t *Task) IsReadyToCalc() bool
- func (t *Task) SetArg1(result int64)
- func (t *Task) SetArg2(result int64)
- func (t *Task) SetResult(result int64) bool
- func (t *Task) SetStatus(newStatus TaskStatus)
- type TaskIDNotExist
- type TaskStatus
- type TaskWithTime
- func (t *TaskWithTime) GetArg1() int64
- func (t *TaskWithTime) GetArg2() int64
- func (t *TaskWithTime) GetOperation() string
- func (t *TaskWithTime) GetPairId() int32
- func (t *TaskWithTime) GetPermissibleDuration() string
- func (t *TaskWithTime) GetResult() int64
- func (t *TaskWithTime) GetStatus() TaskStatus
- func (t *TaskWithTime) GetTimeAtSendingTask() time.Time
- func (t *TaskWithTime) GetWrappedTask() InternalTask
- func (t *TaskWithTime) IsReadyToCalc() bool
- func (t *TaskWithTime) SetStatus(newStatus TaskStatus)
- type TaskWithTimeStub
- type TasksHandler
- func (t *TasksHandler) Add(task InternalTask)
- func (t *TasksHandler) CountUpdatedTask()
- func (t *TasksHandler) Get(ind int) InternalTask
- func (t *TasksHandler) Len() int
- func (t *TasksHandler) PopSentTask(taskId int32) (InternalTask, time.Time, bool)
- func (t *TasksHandler) RegisterFirst() (task InternalTask)
- type TasksHandlerStub
- func (s *TasksHandlerStub) Add(task InternalTask)
- func (s *TasksHandlerStub) CountUpdatedTask()
- func (s *TasksHandlerStub) Get(ind int) InternalTask
- func (s *TasksHandlerStub) Len() int
- func (s *TasksHandlerStub) PopSentTask(taskId int) (InternalTask, time.Time, bool)
- func (s *TasksHandlerStub) RegisterFirst() (task InternalTask)
- type TimeoutExecution
- type UserStub
- func (u *UserStub) GetHashedPassword() string
- func (u *UserStub) GetId() int64
- func (u *UserStub) GetLogin() string
- func (u *UserStub) GetPassword() string
- func (u *UserStub) Is(user UserWithPassword) (status bool)
- func (u *UserStub) Marshal() (result []byte, err error)
- func (u *UserStub) SetHashedPassword(salt string) (err error)
- func (u *UserStub) SetId(i int64)
- func (u *UserStub) SetLogin(s string)
- func (u *UserStub) SetPassword(password string)
- type UserWithHashedPassword
- type UserWithPassword
Constants ¶
const ( Ready ExprStatus = "Есть готовые задачи" NoReadyTasks = "Нет готовых задач" Completed = "Выполнено" Cancelled = "Отменено" )
Variables ¶
This section is empty.
Functions ¶
func CallSentTasksFabric ¶
func CallSentTasksFabric() *sentTasksHandler
Types ¶
type AgentResult ¶
func (*AgentResult) Marshal ¶
func (a *AgentResult) Marshal() (result []byte, err error)
type ByteCase ¶
func ConvertToByteCases ¶
func ConvertToByteCases[K, V JsonPayload](reqs []K, resps []V) (result []ByteCase, err error)
type CasesHandler ¶
type CommonExpression ¶
type CommonExpression interface { ShortExpression GetReadyGrpcTask() (GrpcTask, error) GetTasksHandler() CommonTasksHandler UpdateTask(result GrpcResult, timeAt time.Time) (err error) MarshalId() (result []byte, err error) DivideIntoTasks() }
type CommonTask ¶
type CommonTask interface { PairIdHolder GetOperation() string }
type CommonTasksHandler ¶
type CommonTasksHandler interface { Add(task InternalTask) Get(ind int) InternalTask Len() int RegisterFirst() (task InternalTask) CountUpdatedTask() PopSentTask(taskId int32) (InternalTask, time.Time, bool) }
type CommonUser ¶
type DbUser ¶
type DbUser struct {
// contains filtered or unexported fields
}
DbUser -- структура для внутреннего использования (контур db - backend).
func CallDbUserFabric ¶
func WrapIntoDbUser ¶
func WrapIntoDbUser(jsonUser UserWithPassword) (instance *DbUser, err error)
WrapIntoDbUser устанавливает захешированный пароль, пригодный для хранения в db, а также переносит login, используя данные jsonUser.
func (*DbUser) GetHashedPassword ¶
func (*DbUser) Is ¶
func (d *DbUser) Is(user UserWithPassword) (status bool)
Is сравнивает пользовательские экземпляры по соответствию логина и пароля.
func (*DbUser) SetHashedPassword ¶
SetHashedPassword генерирует по salt и устанавливает захешированный пароль.
type EnvVar ¶
type EnvVar struct {
// contains filtered or unexported fields
}
func CallEnvVarFabric ¶
type ExprStatus ¶
type ExprStatus string
type Expression ¶
type Expression struct { Id int `json:"id"` Status atomic.Value `json:"status"` Result atomic.Int64 `json:"result"` // contains filtered or unexported fields }
func CallExpressionFabric ¶
func CallExpressionFabric(postfix []string, id int, ownerId int64, status ExprStatus, tasksHandler *TasksHandler) (newInstance *Expression)
func CallShortExpressionFabric ¶
func CallShortExpressionFabric(exprId int, ownerId int64, status ExprStatus, result int64) (newInstance *Expression)
func (*Expression) DivideIntoTasks ¶
func (e *Expression) DivideIntoTasks()
func (*Expression) GetId ¶
func (e *Expression) GetId() int
func (*Expression) GetOwnerId ¶
func (e *Expression) GetOwnerId() int64
func (*Expression) GetReadyGrpcTask ¶
func (e *Expression) GetReadyGrpcTask() (result GrpcTask, err error)
func (*Expression) GetResult ¶
func (e *Expression) GetResult() int64
func (*Expression) GetStatus ¶
func (e *Expression) GetStatus() ExprStatus
GetStatus потокобезопасен. Не используйте прямой доступ к Status.
func (*Expression) GetTasksHandler ¶
func (e *Expression) GetTasksHandler() CommonTasksHandler
func (*Expression) Marshal ¶
func (e *Expression) Marshal() (result []byte, err error)
func (*Expression) MarshalId ¶
func (e *Expression) MarshalId() (result []byte, err error)
func (*Expression) MarshalJSON ¶
func (e *Expression) MarshalJSON() (result []byte, err error)
func (*Expression) UpdateTask ¶
func (e *Expression) UpdateTask(result GrpcResult, timeAtReceiveTask time.Time) (err error)
type ExpressionJsonStub ¶
type ExpressionJsonStub struct {
ID int `json:"id"`
}
func (ExpressionJsonStub) Marshal ¶
func (e ExpressionJsonStub) Marshal() (result []byte, err error)
type ExpressionJsonTitle ¶
type ExpressionJsonTitle struct {
Expression ShortExpression `json:"expression"`
}
func (*ExpressionJsonTitle) Marshal ¶
func (e *ExpressionJsonTitle) Marshal() (result []byte, err error)
type ExpressionJsonTitleStub ¶
type ExpressionJsonTitleStub struct {
Expression ExpressionStub `json:"expression"`
}
func (*ExpressionJsonTitleStub) Marshal ¶
func (e *ExpressionJsonTitleStub) Marshal() (result []byte, err error)
type ExpressionStub ¶
type ExpressionStub struct { Id int `json:"id"` Status ExprStatus `json:"status"` Result int64 `json:"result"` TasksHandler *TasksHandlerStub }
func (*ExpressionStub) DivideIntoTasks ¶
func (s *ExpressionStub) DivideIntoTasks()
func (*ExpressionStub) GetId ¶
func (s *ExpressionStub) GetId() int
func (*ExpressionStub) GetOwnerId ¶
func (s *ExpressionStub) GetOwnerId() int64
func (*ExpressionStub) GetReadyGrpcTask ¶
func (s *ExpressionStub) GetReadyGrpcTask() (GrpcTask, error)
func (*ExpressionStub) GetResult ¶
func (s *ExpressionStub) GetResult() int64
func (*ExpressionStub) GetStatus ¶
func (s *ExpressionStub) GetStatus() ExprStatus
func (*ExpressionStub) GetTasksHandler ¶
func (s *ExpressionStub) GetTasksHandler() CommonTasksHandler
func (*ExpressionStub) Marshal ¶
func (s *ExpressionStub) Marshal() (result []byte, err error)
func (*ExpressionStub) MarshalId ¶
func (s *ExpressionStub) MarshalId() (result []byte, err error)
func (*ExpressionStub) UpdateTask ¶
func (s *ExpressionStub) UpdateTask(result GrpcResult, _ time.Time) (err error)
type ExpressionsJsonTitle ¶
type ExpressionsJsonTitle struct {
Expressions []ShortExpression `json:"expressions"`
}
func (*ExpressionsJsonTitle) Marshal ¶
func (e *ExpressionsJsonTitle) Marshal() (result []byte, err error)
type ExpressionsJsonTitleStub ¶
type ExpressionsJsonTitleStub struct {
Expressions []ExpressionStub `json:"expressions"`
}
func (*ExpressionsJsonTitleStub) Marshal ¶
func (e *ExpressionsJsonTitleStub) Marshal() (result []byte, err error)
type GrpcResult ¶
type GrpcResult interface { PairIdHolder ResultHolder }
type GrpcTask ¶
type GrpcTask interface { CommonTask GetArg1() int64 GetArg2() int64 GetPermissibleDuration() string }
GrpcTask должен реализовывать только TaskWithTime, его stub-ы и orchestrator.TaskToSend
type HttpCasesHandler ¶
type HttpCasesHandler[K, V JsonPayload] struct { RequestsToSend []K ExpectedResponses []V HttpMethod string UrlTarget string ExpectedHttpCode int }
func (*HttpCasesHandler[K, V]) GetExpectedHttpCode ¶
func (h *HttpCasesHandler[K, V]) GetExpectedHttpCode() int
func (*HttpCasesHandler[K, V]) GetHttpMethod ¶
func (h *HttpCasesHandler[K, V]) GetHttpMethod() string
func (*HttpCasesHandler[K, V]) GetUrlTarget ¶
func (h *HttpCasesHandler[K, V]) GetUrlTarget() string
type InternalTask ¶
type InternalTask interface { CommonTask GetArg1() (int64, bool) GetArg2() (int64, bool) GetOperation() string ResultHolder GetStatus() TaskStatus GetPermissibleDuration() time.Duration IsReadyToCalc() bool SetStatus(newStatus TaskStatus) SetArg1(int64) SetArg2(int64) SetResult(result int64) bool }
InternalTask реализует Task-и, которые обращаются исключительно внутри оркестратора и не используются для передачи через GRPC.
type JsonPayload ¶
JsonPayload реализует тот же интерфейс, что и json.Marshaler, только метод с другим названием
type JsonUser ¶
type JsonUser struct { Login string `json:"login"` Password string `json:"password"` // contains filtered or unexported fields }
JsonUser -- структура для frontend-использования (контур frontend - backend).
func CallJsonUserFabric ¶
func CallJsonUserFabric() *JsonUser
func (*JsonUser) GetPassword ¶
func (*JsonUser) SetPassword ¶
type JwtTokenJsonWrapperStub ¶
type JwtTokenJsonWrapperStub struct {
Token string `json:"token"`
}
func (*JwtTokenJsonWrapperStub) Marshal ¶
func (j *JwtTokenJsonWrapperStub) Marshal() (result []byte, err error)
type NoReadyTask ¶
type NoReadyTask struct { }
func (NoReadyTask) Error ¶
func (n NoReadyTask) Error() string
type OneReadyTaskBug ¶
type OneReadyTaskBug struct {
ExprId int
}
func (OneReadyTaskBug) Error ¶
func (n OneReadyTaskBug) Error() string
type PairIdHolder ¶
type PairIdHolder interface {
GetPairId() int32
}
type RequestJsonStub ¶
func (*RequestJsonStub) Marshal ¶
func (r *RequestJsonStub) Marshal() (result []byte, err error)
type ResultHolder ¶
type ResultHolder interface {
GetResult() int64
}
type ServerMuxHttpCasesHandler ¶
type ServerMuxHttpCasesHandler[K, V JsonPayload] struct { RequestsToSend []K ExpectedResponses []V HttpMethod string UrlTemplate string UrlTarget string ExpectedHttpCode int }
func (*ServerMuxHttpCasesHandler[K, V]) GetExpectedHttpCode ¶
func (s *ServerMuxHttpCasesHandler[K, V]) GetExpectedHttpCode() int
func (*ServerMuxHttpCasesHandler[K, V]) GetHttpMethod ¶
func (s *ServerMuxHttpCasesHandler[K, V]) GetHttpMethod() string
func (*ServerMuxHttpCasesHandler[K, V]) GetUrlTarget ¶
func (s *ServerMuxHttpCasesHandler[K, V]) GetUrlTarget() string
type ShortExpression ¶
type ShortExpression interface { JsonPayload GetId() int GetStatus() ExprStatus GetResult() int64 GetOwnerId() int64 }
ShortExpression -- урезанная версия Expression для возврата информации о выражении, не включая в этот вывод Task-и. Содержит только методы доступа к полям.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
func CallTaskFabric ¶
func CallTaskFabric(pairId int32, arg1 interface{}, arg2 interface{}, operation string, status TaskStatus) (newInstance *Task)
CallTaskFabric arg1 и arg2 должны быть либо nil, либо int(8/32/64)
func CallTaskWithTimeFabric ¶
func CallTaskWithTimeFabric(pairId int32, arg1 interface{}, arg2 interface{}, operation string, permissibleTime time.Duration, status TaskStatus) (newInstance *Task)
CallTaskWithTimeFabric arg1 и arg2 должны быть либо nil, либо int(8/32/64)
func (*Task) GetOperation ¶
func (*Task) GetPermissibleDuration ¶
func (*Task) IsReadyToCalc ¶
type TaskIDNotExist ¶
type TaskIDNotExist struct {
// contains filtered or unexported fields
}
func (TaskIDNotExist) Error ¶
func (t TaskIDNotExist) Error() string
type TaskStatus ¶
type TaskStatus int
const ( ReadyToCalc TaskStatus = iota Sent WaitingOtherTasks Calculated )
type TaskWithTime ¶
type TaskWithTime struct {
// contains filtered or unexported fields
}
func (*TaskWithTime) GetArg1 ¶
func (t *TaskWithTime) GetArg1() int64
func (*TaskWithTime) GetArg2 ¶
func (t *TaskWithTime) GetArg2() int64
func (*TaskWithTime) GetOperation ¶
func (t *TaskWithTime) GetOperation() string
func (*TaskWithTime) GetPairId ¶
func (t *TaskWithTime) GetPairId() int32
func (*TaskWithTime) GetPermissibleDuration ¶
func (t *TaskWithTime) GetPermissibleDuration() string
func (*TaskWithTime) GetResult ¶
func (t *TaskWithTime) GetResult() int64
func (*TaskWithTime) GetStatus ¶
func (t *TaskWithTime) GetStatus() TaskStatus
func (*TaskWithTime) GetTimeAtSendingTask ¶
func (t *TaskWithTime) GetTimeAtSendingTask() time.Time
func (*TaskWithTime) GetWrappedTask ¶
func (t *TaskWithTime) GetWrappedTask() InternalTask
func (*TaskWithTime) IsReadyToCalc ¶
func (t *TaskWithTime) IsReadyToCalc() bool
func (*TaskWithTime) SetStatus ¶
func (t *TaskWithTime) SetStatus(newStatus TaskStatus)
type TaskWithTimeStub ¶
func (*TaskWithTimeStub) GetArg1 ¶
func (s *TaskWithTimeStub) GetArg1() int64
func (*TaskWithTimeStub) GetArg2 ¶
func (s *TaskWithTimeStub) GetArg2() int64
func (*TaskWithTimeStub) GetOperation ¶
func (s *TaskWithTimeStub) GetOperation() string
func (*TaskWithTimeStub) GetPairId ¶
func (s *TaskWithTimeStub) GetPairId() int32
func (*TaskWithTimeStub) GetPermissibleDuration ¶
func (s *TaskWithTimeStub) GetPermissibleDuration() string
type TasksHandler ¶
type TasksHandler struct {
// contains filtered or unexported fields
}
TasksHandler - обёртка над pkg.Stack с дополнительными методами. Нужен для обработки случаев, когда несколько Task-ов готовы и нужно продолжить работу других Task-ов, зависящие от первых. В случае, когда все необходимые Task-и обновлены, их результаты записываются в зависимый Task, и дальше он отправляется для дальнейшей обработки. Для работы с TaskWithTime встроена отдельная структура.
func CallTasksHandlerFabric ¶
func CallTasksHandlerFabric() (newInstance *TasksHandler)
func (*TasksHandler) Add ¶
func (t *TasksHandler) Add(task InternalTask)
func (*TasksHandler) CountUpdatedTask ¶
func (t *TasksHandler) CountUpdatedTask()
CountUpdatedTask обновляет число отправленных тасок. Обязателен к вызову, если любой Task, указатель которого хранится в экземпляре этой структуры, был обновлён.
func (*TasksHandler) Get ¶
func (t *TasksHandler) Get(ind int) InternalTask
func (*TasksHandler) Len ¶
func (t *TasksHandler) Len() int
func (*TasksHandler) PopSentTask ¶
func (t *TasksHandler) PopSentTask(taskId int32) (InternalTask, time.Time, bool)
func (*TasksHandler) RegisterFirst ¶
func (t *TasksHandler) RegisterFirst() (task InternalTask)
RegisterFirst возвращает первую задачу, не удаляет её, но запоминает и не выдаёт повторно в дальнейшем. Удаляет в том случае, если задача не будет использоваться для вычисления других задач. Для простого получения задачи используйте Get.
type TasksHandlerStub ¶
type TasksHandlerStub struct {
Buf map[int32]InternalTask
}
func (*TasksHandlerStub) Add ¶
func (s *TasksHandlerStub) Add(task InternalTask)
func (*TasksHandlerStub) CountUpdatedTask ¶
func (s *TasksHandlerStub) CountUpdatedTask()
func (*TasksHandlerStub) Get ¶
func (s *TasksHandlerStub) Get(ind int) InternalTask
func (*TasksHandlerStub) Len ¶
func (s *TasksHandlerStub) Len() int
func (*TasksHandlerStub) PopSentTask ¶
func (s *TasksHandlerStub) PopSentTask(taskId int) (InternalTask, time.Time, bool)
func (*TasksHandlerStub) RegisterFirst ¶
func (s *TasksHandlerStub) RegisterFirst() (task InternalTask)
type TimeoutExecution ¶
type TimeoutExecution struct {
// contains filtered or unexported fields
}
func (TimeoutExecution) Error ¶
func (t TimeoutExecution) Error() string
type UserStub ¶
type UserStub struct { Login string `json:"login"` Password string `json:"password"` Id int64 // contains filtered or unexported fields }
func (*UserStub) GetHashedPassword ¶
func (*UserStub) GetPassword ¶
func (*UserStub) Is ¶
func (u *UserStub) Is(user UserWithPassword) (status bool)
func (*UserStub) SetHashedPassword ¶
func (*UserStub) SetPassword ¶
type UserWithHashedPassword ¶
type UserWithHashedPassword interface { CommonUser GetHashedPassword() string SetHashedPassword(salt string) (err error) Is(password UserWithPassword) bool }
type UserWithPassword ¶
type UserWithPassword interface { CommonUser GetPassword() string SetPassword(password string) }