Documentation
¶
Index ¶
- func AuthenticationMiddleware(next http.Handler, audience string, issuer string) http.Handler
- func AuthorizationControlListHasAccess(ctx context.Context, action string, subject string) (error, bool)
- func DBErrorIsRecordNotFound(err error) bool
- func DBPropertiesFromMap(propsMap map[string]string) datatypes.JSONMap
- func DBPropertiesToMap(props datatypes.JSONMap) map[string]string
- func GetEnv(key, fallback string) string
- func GetIp(r *http.Request) string
- func GetLocalIP() string
- func GetMacAddress() string
- func StreamAuthInterceptor(audience string, issuer string) grpc.StreamServerInterceptor
- func ToContext(ctx context.Context, service *Service) context.Context
- func UnaryAuthInterceptor(audience string, issuer string) grpc.UnaryServerInterceptor
- type AuthenticationClaims
- type BaseModel
- type BaseModelI
- type JSONWebKeys
- type Jwks
- type Migration
- type Option
- func Datastore(ctx context.Context, postgresqlConnection string, readOnly bool) Option
- func GrpcServer(grpcServer *grpc.Server) Option
- func HttpHandler(h http.Handler) Option
- func HttpOptions(httpOpts *server.Options) Option
- func NoopHttpOptions() Option
- func RegisterPublisher(reference string, queueUrl string) Option
- func RegisterSubscriber(reference string, queueUrl string, concurrency int, handler SubscribeWorker) Option
- func ServerListener(listener net.Listener) Option
- func Translations(translationsFolder string, languages ...string) Option
- type Queue
- type Service
- func (s *Service) AddCleanupMethod(f func())
- func (s *Service) AddHealthCheck(checker health.Checker)
- func (s *Service) AddPreStartMethod(f func(s *Service))
- func (s *Service) Bundle() *i18n.Bundle
- func (s *Service) DB(ctx context.Context, readOnly bool) *gorm.DB
- func (s *Service) Init(opts ...Option)
- func (s *Service) InvokeRestService(ctx context.Context, method string, authorizationUrl string, ...) (int, []byte, error)
- func (s *Service) MigrateDatastore(ctx context.Context, migrationsDirPath string, migrations ...interface{}) error
- func (s Service) Publish(ctx context.Context, reference string, payload interface{}) error
- func (s Service) QID(ctx context.Context, payload []byte) (string, error)
- func (s Service) QObject(ctx context.Context, model BaseModelI) ([]byte, map[string]string, error)
- func (s *Service) Run(ctx context.Context, address string) error
- func (s *Service) Stop()
- func (s *Service) Translate(request interface{}, messageId string) string
- func (s *Service) TranslateWithMap(request interface{}, messageId string, variables map[string]interface{}) string
- func (s *Service) TranslateWithMapAndCount(request interface{}, messageId string, variables map[string]interface{}, ...) string
- type SubscribeWorker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthenticationMiddleware ¶ added in v1.0.7
AuthenticationMiddleware Simple http middleware function to verify and extract authentication data supplied in a jwt as authorization bearer token
func AuthorizationControlListHasAccess ¶ added in v1.0.5
func DBErrorIsRecordNotFound ¶ added in v1.2.6
func DBPropertiesFromMap ¶ added in v1.2.6
func DBPropertiesToMap ¶ added in v1.2.6
func GetLocalIP ¶
func GetLocalIP() string
func GetMacAddress ¶
func GetMacAddress() string
func StreamAuthInterceptor ¶ added in v1.0.7
func StreamAuthInterceptor(audience string, issuer string) grpc.StreamServerInterceptor
StreamAuthInterceptor An authentication claims extractor that will always verify the information flowing in the streams as true jwt claims
func UnaryAuthInterceptor ¶ added in v1.0.7
func UnaryAuthInterceptor(audience string, issuer string) grpc.UnaryServerInterceptor
Types ¶
type AuthenticationClaims ¶ added in v1.0.7
type AuthenticationClaims struct {
ProfileID string `json:"sub,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
PartitionID string `json:"partition_id,omitempty"`
AccessID string `json:"access_id,omitempty"`
Roles []string `json:"roles,omitempty"`
jwt.StandardClaims
}
AuthenticationClaims Create a struct that will be encoded to a JWT. We add jwt.StandardClaims as an embedded type, to provide fields like expiry time
func ClaimsFromContext ¶ added in v1.0.7
func ClaimsFromContext(ctx context.Context) *AuthenticationClaims
ClaimsFromContext extracts authentication claims from the supplied context if any exist
func ClaimsFromMap ¶ added in v1.1.0
func ClaimsFromMap(m map[string]string) *AuthenticationClaims
ClaimsFromMap extracts authentication claims from the supplied map if they exist
func (*AuthenticationClaims) AsMetadata ¶ added in v1.0.7
func (a *AuthenticationClaims) AsMetadata() map[string]string
AsMetadata Creates a string map to be used as metadata in queue data
func (*AuthenticationClaims) ClaimsToContext ¶ added in v1.0.7
func (a *AuthenticationClaims) ClaimsToContext(ctx context.Context) context.Context
ClaimsToContext adds authentication claims to the current supplied context
type BaseModel ¶
type BaseModel struct {
ID string `gorm:"type:varchar(50);primary_key"`
CreatedAt time.Time
ModifiedAt time.Time
Version uint32 `gorm:"DEFAULT 0"`
TenantID string `gorm:"type:varchar(50);"`
PartitionID string `gorm:"type:varchar(50);"`
DeletedAt gorm.DeletedAt `sql:"index"`
}
BaseModel Our simple table holding all the migration data
func (*BaseModel) BeforeSave ¶ added in v1.2.9
BeforeSave Ensures we update a migrations time stamps
func (*BaseModel) BeforeUpdate ¶
BeforeUpdate Updates time stamp every time we update status of a migration
type BaseModelI ¶
type BaseModelI interface {
GetID() string
}
type JSONWebKeys ¶ added in v1.1.7
type Jwks ¶ added in v1.1.7
type Jwks struct {
Keys []JSONWebKeys `json:"keys"`
}
type Migration ¶
type Migration struct {
BaseModel
Name string `gorm:"type:varchar(50);uniqueIndex"`
Patch string `gorm:"type:text"`
AppliedAt sql.NullTime
}
Migration Our simple table holding all the migration data
type Option ¶
type Option func(service *Service)
func GrpcServer ¶
func HttpHandler ¶
func HttpOptions ¶
func NoopHttpOptions ¶ added in v1.2.15
func NoopHttpOptions() Option
func RegisterPublisher ¶
func RegisterSubscriber ¶
func RegisterSubscriber(reference string, queueUrl string, concurrency int, handler SubscribeWorker) Option
func ServerListener ¶
func Translations ¶ added in v1.0.5
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func FromContext ¶
func NewService ¶
func (*Service) AddCleanupMethod ¶
func (s *Service) AddCleanupMethod(f func())
func (*Service) AddHealthCheck ¶
func (*Service) AddPreStartMethod ¶ added in v1.1.3
func (*Service) InvokeRestService ¶ added in v1.0.15
func (*Service) MigrateDatastore ¶
func (s *Service) MigrateDatastore(ctx context.Context, migrationsDirPath string, migrations ...interface{}) error
MigrateDatastore finds missing migrations and records them in the database