Documentation
¶
Overview ¶
Package client is a generated GoMock package.
Index ¶
- Variables
- func NewClientRequestLogSubscriber(subscription map[string]*pubsub.Subscription, ...) subscriber.Subscriber
- func ParseQueryParams(path string, params interface{}) string
- func RegisterClientRequestLogSubscriber(db *gorm.DB, subscription map[string]*pubsub.Subscription)
- func Sethystrix(nameClient string)
- type AuthorizationType
- type AuthorizationTypeStruct
- type ClientRequestLog
- type ClientRequestLogService
- type ClientRequestLogServiceInterface
- type ClientRequestLogSubscriber
- type GenericHTTPClient
- type HTTPClient
- func (c *HTTPClient) AddAuthentication(ctx context.Context, authorizationType AuthorizationType)
- func (c *HTTPClient) CallClient(ctx context.Context, path string, method constant.HTTPMethod, ...) *ResponseError
- func (c *HTTPClient) CallClientWithBaseURLGiven(ctx context.Context, url string, method constant.HTTPMethod, ...) *ResponseError
- func (c *HTTPClient) CallClientWithCachingInRedis(ctx context.Context, durationInSecond int, path string, ...) *ResponseError
- func (c *HTTPClient) CallClientWithCachingInRedisWithDifferentKey(ctx context.Context, durationInSecond int, path string, ...) *ResponseError
- func (c *HTTPClient) CallClientWithCircuitBreaker(ctx context.Context, path string, method constant.HTTPMethod, ...) *ResponseError
- func (c *HTTPClient) CallClientWithRequestInBytes(ctx context.Context, path string, method constant.HTTPMethod, request []byte, ...) *ResponseError
- func (c *HTTPClient) Do(req *http.Request) (string, *ResponseError)
- type MockGenericHTTPClient
- func (m *MockGenericHTTPClient) AddAuthentication(ctx context.Context, authorizationType AuthorizationType)
- func (m *MockGenericHTTPClient) CallClient(ctx context.Context, path string, method constants.HTTPMethod, ...) *ResponseError
- func (m *MockGenericHTTPClient) CallClientWithBaseURLGiven(ctx context.Context, url string, method constants.HTTPMethod, ...) *ResponseError
- func (m *MockGenericHTTPClient) CallClientWithCachingInRedis(ctx context.Context, durationInSecond int, path string, ...) *ResponseError
- func (m *MockGenericHTTPClient) CallClientWithCachingInRedisWithDifferentKey(ctx context.Context, durationInSecond int, path, pathToBeStoredAsKey string, ...) *ResponseError
- func (m *MockGenericHTTPClient) CallClientWithCircuitBreaker(ctx context.Context, path string, method constants.HTTPMethod, ...) *ResponseError
- func (m *MockGenericHTTPClient) CallClientWithRequestInBytes(ctx context.Context, path string, method constants.HTTPMethod, request []byte, ...) *ResponseError
- func (m *MockGenericHTTPClient) Do(req *http.Request) (string, *ResponseError)
- func (m *MockGenericHTTPClient) EXPECT() *MockGenericHTTPClientMockRecorder
- type MockGenericHTTPClientMockRecorder
- func (mr *MockGenericHTTPClientMockRecorder) AddAuthentication(ctx, authorizationType interface{}) *gomock.Call
- func (mr *MockGenericHTTPClientMockRecorder) CallClient(ctx, path, method, request, result interface{}) *gomock.Call
- func (mr *MockGenericHTTPClientMockRecorder) CallClientWithBaseURLGiven(ctx, url, method, request, result interface{}) *gomock.Call
- func (mr *MockGenericHTTPClientMockRecorder) CallClientWithCachingInRedis(ctx, durationInSecond, path, method, request, result interface{}) *gomock.Call
- func (mr *MockGenericHTTPClientMockRecorder) CallClientWithCachingInRedisWithDifferentKey(...) *gomock.Call
- func (mr *MockGenericHTTPClientMockRecorder) CallClientWithCircuitBreaker(ctx, path, method, request, result interface{}) *gomock.Call
- func (mr *MockGenericHTTPClientMockRecorder) CallClientWithRequestInBytes(ctx, path, method, request, result interface{}) *gomock.Call
- func (mr *MockGenericHTTPClientMockRecorder) Do(req interface{}) *gomock.Call
- type ResponseError
Constants ¶
This section is empty.
Variables ¶
var ( Basic = AuthorizationType(AuthorizationTypeStruct{HeaderName: "authorization", HeaderType: "basic", HeaderTypeValue: "basic "}) Bearer = AuthorizationType(AuthorizationTypeStruct{HeaderName: "authorization", HeaderType: "bearer", HeaderTypeValue: "bearer "}) AccessToken = AuthorizationType(AuthorizationTypeStruct{HeaderName: "access-token", HeaderType: "auth0", HeaderTypeValue: ""}) Secret = AuthorizationType(AuthorizationTypeStruct{HeaderName: "secret", HeaderType: "secret", HeaderTypeValue: ""}) APIKey = AuthorizationType(AuthorizationTypeStruct{HeaderName: "api-key", HeaderType: "api-key", HeaderTypeValue: ""}) )
Enum value for http authorization type
Functions ¶
func NewClientRequestLogSubscriber ¶
func NewClientRequestLogSubscriber( subscription map[string]*pubsub.Subscription, service ClientRequestLogServiceInterface, ) subscriber.Subscriber
func ParseQueryParams ¶
ParseQueryParams .
func RegisterClientRequestLogSubscriber ¶
func RegisterClientRequestLogSubscriber(db *gorm.DB, subscription map[string]*pubsub.Subscription)
Types ¶
type AuthorizationType ¶
type AuthorizationType AuthorizationTypeStruct
AuthorizationType represents the enum for http authorization type
type AuthorizationTypeStruct ¶
type AuthorizationTypeStruct struct { HeaderName string HeaderType string HeaderTypeValue string Token string }
AuthorizationTypeStruct represents struct of Authorization Type
type ClientRequestLog ¶
type ClientRequestLog struct { ID uuid.UUID `json:"id" gorm:"primaryKey,not null"` CalledAt time.Time `json:"called_at" gorm:"not null"` RequestID uuid.UUID `json:"request_id" gorm:"index:request_id_idx"` URLPath string `json:"url_path" gorm:"index:url_path_idx"` Method string `json:"method" gorm:"index:method_idx"` Headers string `json:"headers"` ClientName string `json:"client_name" gorm:"not null"` RequestPayload string `json:"request_payload" gorm:"null"` ResponsePayload string `json:"response_payload" gorm:"not null"` Latency int `json:"latency" gorm:"not null"` StatusCode int `json:"status_code" gorm:"not null"` TriggeredBy uuid.UUID `json:"created_by" gorm:"not null"` CreatedAt time.Time `json:"created_at" gorm:"not null"` CreatedBy uuid.UUID `json:"created_by" gorm:"not null"` }
type ClientRequestLogService ¶
type ClientRequestLogService struct {
// contains filtered or unexported fields
}
func (*ClientRequestLogService) Add ¶
func (s *ClientRequestLogService) Add(ctx context.Context, clientRequestLog *ClientRequestLog) error
type ClientRequestLogServiceInterface ¶
type ClientRequestLogServiceInterface interface {
Add(ctx context.Context, clientRequestLog *ClientRequestLog) error
}
func NewClientRequestLogService ¶
func NewClientRequestLogService( repository repository.ImmutableGenericRepositoryInterface, ) ClientRequestLogServiceInterface
type ClientRequestLogSubscriber ¶
type ClientRequestLogSubscriber struct {
// contains filtered or unexported fields
}
func (*ClientRequestLogSubscriber) Run ¶
func (s *ClientRequestLogSubscriber) Run(ctx context.Context)
type GenericHTTPClient ¶
type GenericHTTPClient interface { Do(req *http.Request) (string, *ResponseError) CallClient(ctx context.Context, path string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError CallClientWithCachingInRedis(ctx context.Context, durationInSecond int, path string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError CallClientWithCachingInRedisWithDifferentKey(ctx context.Context, durationInSecond int, path string, pathToBeStoredAsKey string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError CallClientWithCircuitBreaker(ctx context.Context, path string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError CallClientWithBaseURLGiven(ctx context.Context, url string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError CallClientWithRequestInBytes(ctx context.Context, path string, method constant.HTTPMethod, request []byte, result interface{}) *ResponseError AddAuthentication(ctx context.Context, authorizationType AuthorizationType) }
GenericHTTPClient represents an interface to generalize an object to implement HTTPClient
func NewHTTPClient ¶
func NewHTTPClient( config HTTPClient, redisClient *redis.Client, log *logrus.Logger, ) GenericHTTPClient
NewHTTPClient creates the new http client
type HTTPClient ¶
type HTTPClient struct { APIURL string HTTPClient *http.Client MaxNetworkRetries int UseNormalSleep bool AuthorizationTypes []AuthorizationType ClientName string // contains filtered or unexported fields }
HTTPClient represents the service http client
func (*HTTPClient) AddAuthentication ¶
func (c *HTTPClient) AddAuthentication(ctx context.Context, authorizationType AuthorizationType)
AddAuthentication do add authentication
func (*HTTPClient) CallClient ¶
func (c *HTTPClient) CallClient(ctx context.Context, path string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError
CallClient do call client
func (*HTTPClient) CallClientWithBaseURLGiven ¶
func (c *HTTPClient) CallClientWithBaseURLGiven(ctx context.Context, url string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError
CallClientWithBaseURLGiven do call client with base url given
func (*HTTPClient) CallClientWithCachingInRedis ¶
func (c *HTTPClient) CallClientWithCachingInRedis(ctx context.Context, durationInSecond int, path string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError
CallClientWithCachingInRedis call client with caching in redis
func (*HTTPClient) CallClientWithCachingInRedisWithDifferentKey ¶
func (c *HTTPClient) CallClientWithCachingInRedisWithDifferentKey(ctx context.Context, durationInSecond int, path string, pathToBeStoredAsKey string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError
CallClientWithCachingInRedisWithDifferentKey call client with caching in redis with different key
func (*HTTPClient) CallClientWithCircuitBreaker ¶
func (c *HTTPClient) CallClientWithCircuitBreaker(ctx context.Context, path string, method constant.HTTPMethod, request interface{}, result interface{}) *ResponseError
CallClientWithCircuitBreaker do call client with circuit breaker (async)
func (*HTTPClient) CallClientWithRequestInBytes ¶
func (c *HTTPClient) CallClientWithRequestInBytes(ctx context.Context, path string, method constant.HTTPMethod, request []byte, result interface{}) *ResponseError
CallClientWithRequestInBytes do call client with request in bytes and omit acknowledge process - specific case for consumer
func (*HTTPClient) Do ¶
func (c *HTTPClient) Do(req *http.Request) (string, *ResponseError)
Do calls the api http request and parse the response into v
type MockGenericHTTPClient ¶
type MockGenericHTTPClient struct {
// contains filtered or unexported fields
}
MockGenericHTTPClient is a mock of GenericHTTPClient interface.
func NewMockGenericHTTPClient ¶
func NewMockGenericHTTPClient(ctrl *gomock.Controller) *MockGenericHTTPClient
NewMockGenericHTTPClient creates a new mock instance.
func (*MockGenericHTTPClient) AddAuthentication ¶
func (m *MockGenericHTTPClient) AddAuthentication(ctx context.Context, authorizationType AuthorizationType)
AddAuthentication mocks base method.
func (*MockGenericHTTPClient) CallClient ¶
func (m *MockGenericHTTPClient) CallClient(ctx context.Context, path string, method constants.HTTPMethod, request, result interface{}) *ResponseError
CallClient mocks base method.
func (*MockGenericHTTPClient) CallClientWithBaseURLGiven ¶
func (m *MockGenericHTTPClient) CallClientWithBaseURLGiven(ctx context.Context, url string, method constants.HTTPMethod, request, result interface{}) *ResponseError
CallClientWithBaseURLGiven mocks base method.
func (*MockGenericHTTPClient) CallClientWithCachingInRedis ¶
func (m *MockGenericHTTPClient) CallClientWithCachingInRedis(ctx context.Context, durationInSecond int, path string, method constants.HTTPMethod, request, result interface{}) *ResponseError
CallClientWithCachingInRedis mocks base method.
func (*MockGenericHTTPClient) CallClientWithCachingInRedisWithDifferentKey ¶
func (m *MockGenericHTTPClient) CallClientWithCachingInRedisWithDifferentKey(ctx context.Context, durationInSecond int, path, pathToBeStoredAsKey string, method constants.HTTPMethod, request, result interface{}) *ResponseError
CallClientWithCachingInRedisWithDifferentKey mocks base method.
func (*MockGenericHTTPClient) CallClientWithCircuitBreaker ¶
func (m *MockGenericHTTPClient) CallClientWithCircuitBreaker(ctx context.Context, path string, method constants.HTTPMethod, request, result interface{}) *ResponseError
CallClientWithCircuitBreaker mocks base method.
func (*MockGenericHTTPClient) CallClientWithRequestInBytes ¶
func (m *MockGenericHTTPClient) CallClientWithRequestInBytes(ctx context.Context, path string, method constants.HTTPMethod, request []byte, result interface{}) *ResponseError
CallClientWithRequestInBytes mocks base method.
func (*MockGenericHTTPClient) Do ¶
func (m *MockGenericHTTPClient) Do(req *http.Request) (string, *ResponseError)
Do mocks base method.
func (*MockGenericHTTPClient) EXPECT ¶
func (m *MockGenericHTTPClient) EXPECT() *MockGenericHTTPClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockGenericHTTPClientMockRecorder ¶
type MockGenericHTTPClientMockRecorder struct {
// contains filtered or unexported fields
}
MockGenericHTTPClientMockRecorder is the mock recorder for MockGenericHTTPClient.
func (*MockGenericHTTPClientMockRecorder) AddAuthentication ¶
func (mr *MockGenericHTTPClientMockRecorder) AddAuthentication(ctx, authorizationType interface{}) *gomock.Call
AddAuthentication indicates an expected call of AddAuthentication.
func (*MockGenericHTTPClientMockRecorder) CallClient ¶
func (mr *MockGenericHTTPClientMockRecorder) CallClient(ctx, path, method, request, result interface{}) *gomock.Call
CallClient indicates an expected call of CallClient.
func (*MockGenericHTTPClientMockRecorder) CallClientWithBaseURLGiven ¶
func (mr *MockGenericHTTPClientMockRecorder) CallClientWithBaseURLGiven(ctx, url, method, request, result interface{}) *gomock.Call
CallClientWithBaseURLGiven indicates an expected call of CallClientWithBaseURLGiven.
func (*MockGenericHTTPClientMockRecorder) CallClientWithCachingInRedis ¶
func (mr *MockGenericHTTPClientMockRecorder) CallClientWithCachingInRedis(ctx, durationInSecond, path, method, request, result interface{}) *gomock.Call
CallClientWithCachingInRedis indicates an expected call of CallClientWithCachingInRedis.
func (*MockGenericHTTPClientMockRecorder) CallClientWithCachingInRedisWithDifferentKey ¶
func (mr *MockGenericHTTPClientMockRecorder) CallClientWithCachingInRedisWithDifferentKey(ctx, durationInSecond, path, pathToBeStoredAsKey, method, request, result interface{}) *gomock.Call
CallClientWithCachingInRedisWithDifferentKey indicates an expected call of CallClientWithCachingInRedisWithDifferentKey.
func (*MockGenericHTTPClientMockRecorder) CallClientWithCircuitBreaker ¶
func (mr *MockGenericHTTPClientMockRecorder) CallClientWithCircuitBreaker(ctx, path, method, request, result interface{}) *gomock.Call
CallClientWithCircuitBreaker indicates an expected call of CallClientWithCircuitBreaker.
func (*MockGenericHTTPClientMockRecorder) CallClientWithRequestInBytes ¶
func (mr *MockGenericHTTPClientMockRecorder) CallClientWithRequestInBytes(ctx, path, method, request, result interface{}) *gomock.Call
CallClientWithRequestInBytes indicates an expected call of CallClientWithRequestInBytes.
func (*MockGenericHTTPClientMockRecorder) Do ¶
func (mr *MockGenericHTTPClientMockRecorder) Do(req interface{}) *gomock.Call
Do indicates an expected call of Do.
type ResponseError ¶
type ResponseError struct { Code string `json:"code"` Message string `json:"message"` StatusCode int `json:"statusCode"` Error error `json:"error"` Info string `json:"info"` }
ResponseError represents struct of Authorization Type
func (*ResponseError) FromError ¶
func (e *ResponseError) FromError(err error) *ResponseError