kitexreflect

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 20 Imported by: 0

README

kitex-reflect

An implementation of service reflection for Kitex.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MarshalReflectServiceReqPayload   = idl.MarshalReflectServiceReqPayload
	UnmarshalReflectServiceReqPayload = idl.UnmarshalReflectServiceReqPayload

	MarshalReflectServiceRespPayload   = idl.MarshalReflectServiceRespPayload
	UnmarshalReflectServiceRespPayload = idl.UnmarshalReflectServiceRespPayload
)

Functions

func BuildServiceDescriptor

func BuildServiceDescriptor(payload *idl.ReflectServiceRespPayload) (*descriptor.ServiceDescriptor, error)

BuildServiceDescriptor builds a descriptor.ServiceDescriptor from a ReflectServiceResponse.

func NewGenericClient added in v0.5.0

func NewGenericClient(
	ctx context.Context,
	serviceName string,
	gFactory func(p generic.DescriptorProvider) (generic.Generic, error),
	kcOptions []client.Option,
	providerOpts ...Option,
) (genericclient.Client, error)

NewGenericClient creates a genericclient.Client for a service. gFactory should be a factory function from the generic package.

Types

type Option added in v0.4.0

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

func AutoUpdate added in v0.4.0

func AutoUpdate(interval time.Duration) Option

AutoUpdate tells the description provider to automatically update service descriptor from backend service.

func InitAsync added in v0.4.0

func InitAsync() Option

InitAsync tells the description provider to initialize service descriptor asynchronously, don't wait for the first descriptor being ready.

func WithDebounceInterval added in v0.4.0

func WithDebounceInterval(d time.Duration) Option

WithDebounceInterval sets max interval to debounce requests sent to backend service. The default is 10 seconds.

func WithErrorHandler added in v0.4.0

func WithErrorHandler(f func(err error, msg string)) Option

WithErrorHandler optionally specifies an error handler function for errors happened when updating service descriptor from backend service. By default, it logs error using the klog package.

type ProviderImpl

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

ProviderImpl connects to a Kitex service which has reflection support, it calls the service's method ReflectService to build service descriptor. It implements generic.DescriptorProvider.

func NewDescriptorProvider

func NewDescriptorProvider(
	ctx context.Context,
	serviceName string,
	kcOptions []client.Option,
	providerOpts ...Option,
) (*ProviderImpl, error)

NewDescriptorProvider creates a ProviderImpl which implements generic.DescriptorProvider.

func (*ProviderImpl) Close

func (p *ProviderImpl) Close() error

Close closes the provider and the channel returned by Provide.

func (*ProviderImpl) IsClosed added in v0.2.0

func (p *ProviderImpl) IsClosed() bool

IsClosed checks whether the provider has been closed.

func (*ProviderImpl) Provide

func (p *ProviderImpl) Provide() <-chan *descriptor.ServiceDescriptor

Provide returns a channel for service descriptors.

func (*ProviderImpl) Update

func (p *ProviderImpl) Update(ctx context.Context)

Update triggers updating service descriptor from backend service. The actual rpc requests will be debounced according to debounceInterval. This method is safe to call concurrently.

type ReflectServiceReqPayload

type ReflectServiceReqPayload = idl.ReflectServiceReqPayload

type ReflectServiceRequest

type ReflectServiceRequest = idl.ReflectServiceRequest

type ReflectServiceRespPayload

type ReflectServiceRespPayload = idl.ReflectServiceRespPayload

type ReflectServiceResponse

type ReflectServiceResponse = idl.ReflectServiceResponse

Directories

Path Synopsis
cmd
example
bookinfo/kitex_gen/cwg/bookinfo/details/detailsservice
Code generated by thrift-gen-kitex-reflect.
Code generated by thrift-gen-kitex-reflect.
kitex_gen module

Jump to

Keyboard shortcuts

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