Documentation
¶
Index ¶
- Constants
- Variables
- func AddLogFlagsToCommand(cmd *cobra.Command)
- func ApplyLogModifiers()
- func Connect(ctx context.Context, endpoint string, action ActionFunc) error
- func Dial(ctx context.Context, endpoint string) (*grpc.ClientConn, error)
- func DumpJSON(x interface{}) error
- func EncodeStream(recv RecvFunc) error
- func EncodeWhole(recv RecvFunc) error
- func JSON2Buf(obj interface{}) []byte
- func JSON2Str(x interface{}) string
- func NewStreamServerInterceptorZerolog() grpc.StreamServerInterceptor
- func NewUnaryServerInterceptorZerolog() grpc.UnaryServerInterceptor
- func OverrideLogID(ID string)
- func StatusJSON(code int, ID, msg string) error
- type ActionFunc
- type ClientConfig
- type EventServiceConfig
- type MainConfig
- type MapServiceConfig
- type RecvFunc
- type RegionServiceConfig
- type RegisterableMonitorable
- type ServerConfig
- type StatelessDiscovery
- type StaticConfig
- type TargetConfig
Constants ¶
const ( // DefaultPortKratos is the default port of the Kratos authentication service by ORY DefaultPortKratos = 4434 // DefaultPortKeto is the default port of the Keto autorisation service by ORY DefaultPortKeto = 4466 // DefaultPortCommon is the default port used to hast the service. // This is also the configuration expected by the docker image. DefaultPortCommon = 6000 // DefaultPortMonitoring is the default port used for clear-text HTTP // serving the /metrics route dedicated to Prometheus exporters. DefaultPortMonitoring = 6001 )
Variables ¶
var ( // LoggerContext is the builder of a zerolog.Logger that is exposed to the application so that // options at the CLI might alter the formatting and the output of the logs. LoggerContext = zerolog. New(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}). With().Timestamp() // Logger is a zerolog logger, that can be safely used from any part of the application. // It gathers the format and the output. Logger = LoggerContext.Logger() )
var DefaultDiscovery = NewStaticConfig()
DefaultDiscovery is the default implementation of a discovery. Valued by default to the discovery of test services, all located on localhost and serving default ports.
Functions ¶
func AddLogFlagsToCommand ¶
AddLogFlagsToCommand add to cmd a set of persistent flags that will alter the logging behavior of the current process.
func ApplyLogModifiers ¶
func ApplyLogModifiers()
func Connect ¶
func Connect(ctx context.Context, endpoint string, action ActionFunc) error
Connect establishes a connection to the given service and then call the action.
func Dial ¶
Dial establishes a gRPC connection to the given endpoint using all the mandatory options on the connection (security, behavior)
func DumpJSON ¶
func DumpJSON(x interface{}) error
DumpJSON encodes the argument in JSON and writes the output on os.Stdout
func EncodeStream ¶
EncodeStream dumps a JSON stream where each line is a JSON-encoded object. EncodeStream is initially intended to dump a gRPC stream in JSON at os.Stdout.
func EncodeWhole ¶
EncodeWhole builds an array of all the objects and encodes it in JSON at once. Warning: the whole stream will be buffered!
func JSON2Buf ¶
func JSON2Buf(obj interface{}) []byte
JSON2Buf generates the JSON-encoded form of the given object, stored in the returned byte array. No indentation, no CRLF
func JSON2Str ¶
func JSON2Str(x interface{}) string
JSON2Str generates a string with the JSON representation of the given object. No indentation, everything on one line. Errors ignored.
func NewStreamServerInterceptorZerolog ¶
func NewStreamServerInterceptorZerolog() grpc.StreamServerInterceptor
func NewUnaryServerInterceptorZerolog ¶
func NewUnaryServerInterceptorZerolog() grpc.UnaryServerInterceptor
func OverrideLogID ¶
func OverrideLogID(ID string)
func StatusJSON ¶
StatusJSON encodes a standard error structure and then forwards it to DumpJSON
Types ¶
type ActionFunc ¶
type ActionFunc func(ctx context.Context, cli *grpc.ClientConn) error
ActionFunc names the signature of the hook to be called when the gRPC connection has been established.
type ClientConfig ¶
type ClientConfig struct { Default TargetConfig `yaml:"default" json:"default"` Proxy TargetConfig `yaml:"proxy" json:"proxy"` Maps TargetConfig `yaml:"maps" json:"maps"` Events TargetConfig `yaml:"events" json:"events"` Regions TargetConfig `yaml:"regions" json:"regions"` Kratos TargetConfig `yaml:"kratos" json:"kratos"` Keto TargetConfig `yaml:"keto" json:"keto"` }
func (*ClientConfig) ApplyToDiscovery ¶
func (cfg *ClientConfig) ApplyToDiscovery() error
ApplyToDiscovery
type EventServiceConfig ¶
type EventServiceConfig struct {
PathBase string `yaml:"base" json:"base"`
}
type MainConfig ¶
type MainConfig struct { Client ClientConfig `yaml:"client" json:"client"` Server ServerConfig `yaml:"server" json:"server"` }
type MapServiceConfig ¶
type MapServiceConfig struct {
PathRepository string `yaml:"repository" json:"repository"`
}
type RecvFunc ¶
type RecvFunc func() (interface{}, error)
RecvFunc names the signature of the hook that consumes an input and returns an object for each PDU received. RecvFunc is initially intended to map any object from a gRPC stream into a generic interface{} that is still JSON-encodable.
type RegionServiceConfig ¶
type RegisterableMonitorable ¶
type RegisterableMonitorable interface { // Register must plug the requests handlers of the backend in the grpc.Server Register(grpcServer *grpc.Server) error // Check must return a status of the whole backend, to be returned to the // client for health-check purposes. Check(ctx context.Context) grpc_health_v1.HealthCheckResponse_ServingStatus }
RegisterableMonitorable summaries the expectations on the application backend.
type ServerConfig ¶
type ServerConfig struct { EndpointService string `yaml:"bind" json:"bind"` EndpointMonitor string `yaml:"monitor" json:"monitor"` ServiceType string `yaml:"type" json:"type"` PathKey string `yaml:"key" json:"key"` PathCrt string `yaml:"cert" json:"cert"` MapConfig MapServiceConfig `yaml:"map" json:"map"` EvtConfig EventServiceConfig `yaml:"evt" json:"evt"` RegConfig RegionServiceConfig `yaml:"reg" json:"reg"` }
type StatelessDiscovery ¶
type StatelessDiscovery interface { // Kratos locates an ORY kratos service (Authentication) Kratos() (string, error) // Keto locates an ORY keto service (Authorisation) Keto() (string, error) // Map locates map services in Hegemonie Map() (string, error) // Region locates an hegemonie's region service // Please note that those services are typically sharded. Stateless weighted polling // is only meaningful when it is necessary to instantiate a new Region. Region() (string, error) // Event locates an hegemonie's event services Event() (string, error) }
StatelessDiscovery is the simplest form of Discovery API providing one call per type of service. Each call returns either a usable endpoint string or the error that occurred during the discovery process. The implementation of the StatelessDiscovery interface is responsible for the management of its concurrent accesses.
func NewStaticConfig ¶
func NewStaticConfig() StatelessDiscovery
NewStaticConfig instantiates a StaticConfig with the default endpoint value for each service type.
type StaticConfig ¶
type StaticConfig struct {
// contains filtered or unexported fields
}
StaticConfig is a StatelessDiscovery implementation with a different endpoint for each kind of service, configured once in the application.
func (*StaticConfig) Event ¶
func (d *StaticConfig) Event() (string, error)
Event ... see StatelessDiscovery.Event
func (*StaticConfig) Keto ¶
func (d *StaticConfig) Keto() (string, error)
Keto ... see StatelessDiscovery.Keto
func (*StaticConfig) Kratos ¶
func (d *StaticConfig) Kratos() (string, error)
Kratos ... see StatelessDiscovery.Kratos
func (*StaticConfig) Map ¶
func (d *StaticConfig) Map() (string, error)
Map ... see StatelessDiscovery.Map
func (*StaticConfig) Region ¶
func (d *StaticConfig) Region() (string, error)
Region ... see StatelessDiscovery.Region