service

package module
v0.0.0-...-ee0b3f6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 43 Imported by: 3

README

service

Documentation

Index

Constants

View Source
const (
	CmdFlagIP                = "ip"
	CmdFlagExternalIP        = "eip"
	CmdFlagName              = "name"
	CmdFlagServiceDomain     = "dn"
	CmdFlagAdditionalDomains = "odn"
	CmdFlagCert              = "cert"
	CmdFlagKey               = "key"
	CmdFlagCAAddr            = "ca-addr"
	CmdFlagCACert            = "ca-cert"
	CmdFlagCAApiKey          = "ca-api-key"
	CmdFlagCAApiSecret       = "ca-api-secret"
	CmdFlagRegistry          = "reg"
)

Variables

This section is empty.

Functions

func CACredentials

func CACredentials(ctx context.Context) *ome.ProxyCredentials

func CMD

func CMD(use string, box *Box) *cobra.Command

func Connect

func Connect(ctx context.Context, ofType uint32, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func ConnectToSpecificService

func ConnectToSpecificService(ctx context.Context, serviceID string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func ConnectToSpecificServiceNode

func ConnectToSpecificServiceNode(ctx context.Context, serviceID, nodeName string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func ContextWithBox

func ContextWithBox(ctx context.Context, b *Box) context.Context

func Dial

func Dial(ctx context.Context, st uint32) (*grpc.ClientConn, error)

func GRPCCallOptionsFromContext

func GRPCCallOptionsFromContext(ctx context.Context, ot ...GRPCCallOption) ([]grpc.CallOption, error)

func GetCACertificate

func GetCACertificate(ctx context.Context) *x509.Certificate

func GetCertificate

func GetCertificate(ctx context.Context) *x509.Certificate

func GetClientTLSConfig

func GetClientTLSConfig(ctx context.Context) (*tls.Config, error)

func GetDir

func GetDir(ctx context.Context) string

func GetGatewayAddress

func GetGatewayAddress(ctx context.Context, name string) string

func GetID

func GetID(ctx context.Context) string

func GetName

func GetName(ctx context.Context) string

func GetPrivateKey

func GetPrivateKey(ctx context.Context) crypto.PrivateKey

func GetRegistry

func GetRegistry(ctx context.Context) ome.Registry

func GetSecret

func GetSecret(ctx context.Context) string

Secret returns the application shared secret

func JWT

func JWT(verifier ome.TokenVerifier) *authorizationJWT

func NewDialer

func NewDialer(addr string, opts ...grpc.DialOption) *dialer

func NewJwtVerifier

func NewJwtVerifier(tlsConfig *tls.Config, registry ome.Registry, store JwtInfoStore) ome.TokenVerifier

func NewSyncedStore

func NewSyncedStore(serverAddress string, tls *tls.Config, store JwtInfoStore) *synchronizedStore

func Oauth2

func Oauth2(verifier ome.TokenVerifier, codecs ...securecookie.Codec) *authorizationBearer

func ProxyAuthenticationMiddleware

func ProxyAuthenticationMiddleware(next http.Handler) http.Handler

func SetCMDFlags

func SetCMDFlags(cmd *cobra.Command, box *Box, ignoreFlagName bool)

Types

type Box

type Box struct {
	*Options
	// contains filtered or unexported fields
}

func BoxFromContext

func BoxFromContext(ctx context.Context) *Box

func CreateBox

func CreateBox(opts ...Option) *Box

func (*Box) AllServices

func (box *Box) AllServices() []*ome.ServiceInfo

func (*Box) Connect

func (box *Box) Connect(ofType uint32, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func (*Box) ConnectToSpecificService

func (box *Box) ConnectToSpecificService(serviceID string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func (*Box) ConnectToSpecificServiceNode

func (box *Box) ConnectToSpecificServiceNode(serviceID, nodeName string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func (*Box) DeleteNode

func (box *Box) DeleteNode(serviceType uint32, serviceID string, nodeID string) (*ome.ServiceInfo, bool)

func (*Box) GRPCConnectionDialer

func (box *Box) GRPCConnectionDialer(serviceType uint32, opts ...grpc.DialOption) (Dialer, error)

func (*Box) SaveNode

func (box *Box) SaveNode(serviceType uint32, serviceID string, node *ome.Node) *ome.ServiceInfo

func (*Box) SaveService

func (box *Box) SaveService(serviceType uint32, info *ome.ServiceInfo)

func (*Box) Service

func (box *Box) Service(serviceType uint32) *ome.ServiceInfo

func (*Box) ServiceAddress

func (box *Box) ServiceAddress(name string) (string, error)

func (*Box) ServiceNode

func (box *Box) ServiceNode(serviceType uint32, name string) *ome.Node

func (*Box) SpecificServiceConnectionDialer

func (box *Box) SpecificServiceConnectionDialer(serviceID string, opts ...grpc.DialOption) (Dialer, error)

func (*Box) SpecificServiceNodeConnectionDialer

func (box *Box) SpecificServiceNodeConnectionDialer(serviceID string, nodeName string, opts ...grpc.DialOption) (Dialer, error)

func (*Box) StartHTTPGateway

func (box *Box) StartHTTPGateway(params *HTTPGatewayParams, nOpts ...NodeOption) error

func (*Box) StartHTTPServer

func (box *Box) StartHTTPServer(params *HTTPServerParams, nOpts ...NodeOption) error

func (*Box) StartNode

func (box *Box) StartNode(params *NodeParams, nOpts ...NodeOption) error

func (*Box) StartNodeGateway

func (box *Box) StartNodeGateway(params *NodeGatewayParams, nOpts ...NodeOption) error

func (*Box) StartPublicNodeGateway

func (box *Box) StartPublicNodeGateway(params *PublicNodeGatewayParams, nOpts ...NodeOption) error

func (*Box) Stop

func (box *Box) Stop()

Stop stops all started services and gateways

func (*Box) StopNode

func (box *Box) StopNode(name string)

func (*Box) Update

func (box *Box) Update(opts ...Option)

type Dialer

type Dialer interface {
	Dial() (*grpc.ClientConn, error)
}

func GRPCConnectionDialer

func GRPCConnectionDialer(ctx context.Context, serviceType uint32, opts ...grpc.DialOption) (Dialer, error)

func SpecificServiceConnectionDialer

func SpecificServiceConnectionDialer(ctx context.Context, serviceID string, opts ...grpc.DialOption) (Dialer, error)

func SpecificServiceNodeConnectionDialer

func SpecificServiceNodeConnectionDialer(ctx context.Context, serviceID string, nodeName string, opts ...grpc.DialOption) (Dialer, error)

type GRPCCallOption

type GRPCCallOption int
const (
	CallOptToken GRPCCallOption = iota + 1
	CallOptProxyCredentials
)

type HTTPGatewayParams

type HTTPGatewayParams struct {
	Email          string
	MiddlewareList []mux.MiddlewareFunc
	ProvideRouter  func() *mux.Router
	ServiceType    uint32
	ServiceID      string
	Name           string
	Meta           MD
}

type HTTPServerParams

type HTTPServerParams struct {
	MiddlewareList []mux.MiddlewareFunc
	ProvideRouter  func() *mux.Router
	Security       ome.Security
	ServiceType    uint32
	ServiceID      string
	Name           string
	Meta           MD
}

type JwtInfoStore

type JwtInfoStore interface {
	Save(serviceName string, info *ome.JwtInfo) error
	Get(jti string) (*ome.JwtInfo, error)
	Delete(jti string) error
	DeleteAllFromService(serviceName string) error
	Clear() error
}

func NewMemInfoStore

func NewMemInfoStore() JwtInfoStore

type MD

type MD map[string]string

func Metadata

func Metadata() MD

func (MD) Get

func (m MD) Get(name string) (string, bool)

func (MD) Set

func (m MD) Set(name, value string)

type MuxWrapper

type MuxWrapper func(mux *runtime.ServeMux) http.Handler

type NodeGatewayParams

type NodeGatewayParams struct {
	ServiceName    string
	TargetNodeName string
	NodeName       string
	ServiceType    uint32
	ServiceID      string
	Security       ome.Security
	Binder         WireEndpointFunc
	MuxWrapper     MuxWrapper
	Meta           MD
}

type NodeOption

type NodeOption func(options *nodeOptions)

func GlobalOptions

func GlobalOptions(opts ...Option) NodeOption

func Register

func Register(register bool) NodeOption

func WithInterceptor

func WithInterceptor(interceptors ...ome.GrpcContextUpdater) NodeOption

func WithMeta

func WithMeta(m MD) NodeOption

func WithPort

func WithPort(port int) NodeOption

func WithTLS

func WithTLS(t *tls.Config) NodeOption

type NodeParams

type NodeParams struct {
	RegisterHandlerFunc func(*grpc.Server)
	ServiceType         uint32
	ServiceID           string
	Name                string
	Meta                MD
}

type Option

type Option func(*Options)

Option is an Options object handler function

func CAAddr

func CAAddr(addr string) Option

func CAApiKey

func CAApiKey(apiKey string) Option

CAApiKey returns function that sets the API access key in options

func CAApiSecret

func CAApiSecret(apiSecret string) Option

func CACert

func CACert(cert *x509.Certificate) Option

func CACertFile

func CACertFile(filename string) Option

func CAKey

func CAKey(key crypto.PrivateKey) Option

func CAKeyFIle

func CAKeyFIle(filename string) Option

func Cert

func Cert(cert *x509.Certificate) Option

func CertFile

func CertFile(filename string) Option

func Dir

func Dir(dirname string) Option

func Domain

func Domain(domain string, others ...string) Option

func ExternalIp

func ExternalIp(ip string) Option

func Ip

func Ip(ip string) Option

func Key

func Key(key crypto.PrivateKey) Option

func KeyFIle

func KeyFIle(filename string) Option

func Log

func Log(Filename string) Option

func Name

func Name(name string) Option

func RegAddr

func RegAddr(addr string) Option

func RegApiKey

func RegApiKey(apiKey string) Option

func RegApiSecret

func RegApiSecret(apiSecret string) Option

func Registry

func Registry(reg ome.Registry) Option

type Options

type Options struct {
	// contains filtered or unexported fields
}

func (*Options) BindIP

func (opts *Options) BindIP() string

func (*Options) CACertificate

func (opts *Options) CACertificate() *x509.Certificate

func (*Options) CertificateFilename

func (opts *Options) CertificateFilename() string

func (*Options) ClientMutualTLS

func (opts *Options) ClientMutualTLS() (*tls.Config, error)

func (*Options) ClientTLS

func (opts *Options) ClientTLS() (*tls.Config, error)

func (*Options) Dir

func (opts *Options) Dir() string

func (*Options) Domain

func (opts *Options) Domain() string

func (*Options) Domains

func (opts *Options) Domains() []string

func (*Options) ExternalIP

func (opts *Options) ExternalIP() string

func (*Options) Host

func (opts *Options) Host() string

func (*Options) IP

func (opts *Options) IP() string

func (*Options) IpList

func (opts *Options) IpList() []string

func (*Options) KeyFilename

func (opts *Options) KeyFilename() string

func (*Options) Name

func (opts *Options) Name() string

func (*Options) Registry

func (opts *Options) Registry() (ome.Registry, error)

func (*Options) ServerTLS

func (opts *Options) ServerTLS() (*tls.Config, error)

func (*Options) ServiceCert

func (opts *Options) ServiceCert() *x509.Certificate

func (*Options) ServiceKey

func (opts *Options) ServiceKey() crypto.PrivateKey

func (*Options) StartRegistryServer

func (opts *Options) StartRegistryServer(opt ...Option) (err error)

func (*Options) StopRegistry

func (opts *Options) StopRegistry() error

type PublicNodeGatewayParams

type PublicNodeGatewayParams struct {
	ServiceName    string
	TargetNodeName string
	NodeName       string
	ServiceType    uint32
	ServiceID      string
	Email          string
	Binder         WireEndpointFunc
	MuxWrapper     MuxWrapper
	Meta           MD
}

type WireEndpointFunc

type WireEndpointFunc func(ctx context.Context, serveMux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL