admin

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2021 License: MIT Imports: 31 Imported by: 1

README

admin

Admin plugin use grpc-gateway to provide both REST HTTP and GRPC APIs for integration with external systems.

API Doc

See swagger

Examples

List Clients

$ curl 127.0.0.1:8083/v1/clients

Response:

{
      "clients": [
          {
              "client_id": "ab",
              "username": "",
              "keep_alive": 60,
              "version": 4,
              "remote_addr": "127.0.0.1:51637",
              "local_addr": "127.0.0.1:1883",
              "connected_at": "2020-12-12T12:26:36Z",
              "disconnected_at": null,
              "session_expiry": 7200,
              "max_inflight": 100,
              "inflight_len": 0,
              "max_queue": 100,
              "queue_len": 0,
              "subscriptions_current": 0,
              "subscriptions_total": 0,
              "packets_received_bytes": "54",
              "packets_received_nums": "3",
              "packets_send_bytes": "8",
              "packets_send_nums": "2",
              "message_dropped": "0"
          }
      ],
      "total_count": 1
  }

Filter Subscriptions

$ curl 127.0.0.1:8083/v1/filter_subscriptions?filter_type=1,2,3&match_type=1&topic_name=/a

This curl is able to filter the subscription that the topic name is equal to "/a".

Response:

{
    "subscriptions": [
        {
            "topic_name": "/a",
            "id": 0,
            "qos": 1,
            "no_local": false,
            "retain_as_published": false,
            "retain_handling": 0,
            "client_id": "ab"
        }
    ]
}

Publish Message

$ curl -X POST 127.0.0.1:8083/v1/publish -d '{"topic_name":"a","payload":"test","qos":1}'

This curl will publish the message to the broker.The broker will check if there are matched topics and send the message to the subscribers, just like received a message from a MQTT client.

Documentation

Overview

Package admin is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Package admin is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Package admin is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const Name = "admin"

Variables

View Source
var (
	SubFilterType_name = map[int32]string{
		0: "SUB_FILTER_TYPE_SYS_UNSPECIFIED",
		1: "SUB_FILTER_TYPE_SYS",
		2: "SUB_FILTER_TYPE_SHARED",
		3: "SUB_FILTER_TYPE_NON_SHARED",
	}
	SubFilterType_value = map[string]int32{
		"SUB_FILTER_TYPE_SYS_UNSPECIFIED": 0,
		"SUB_FILTER_TYPE_SYS":             1,
		"SUB_FILTER_TYPE_SHARED":          2,
		"SUB_FILTER_TYPE_NON_SHARED":      3,
	}
)

Enum value maps for SubFilterType.

View Source
var (
	SubMatchType_name = map[int32]string{
		0: "SUB_MATCH_TYPE_MATCH_UNSPECIFIED",
		1: "SUB_MATCH_TYPE_MATCH_NAME",
		2: "SUB_MATCH_TYPE_MATCH_FILTER",
	}
	SubMatchType_value = map[string]int32{
		"SUB_MATCH_TYPE_MATCH_UNSPECIFIED": 0,
		"SUB_MATCH_TYPE_MATCH_NAME":        1,
		"SUB_MATCH_TYPE_MATCH_FILTER":      2,
	}
)

Enum value maps for SubMatchType.

View Source
var DefaultConfig = Config{
	HTTP: HTTPConfig{
		Enable: true,
		Addr:   "127.0.0.1:8083",
	},
	GRPC: GRPCConfig{
		Addr: "unix://./gmqttd.sock",
	},
}

DefaultConfig is the default configuration.

View Source
var ErrNotFound = status.Error(codes.NotFound, "not found")

ErrNotFound represents a not found error.

View Source
var File_client_proto protoreflect.FileDescriptor
View Source
var File_publish_proto protoreflect.FileDescriptor
View Source
var File_subscription_proto protoreflect.FileDescriptor

Functions

func ErrInvalidArgument added in v0.2.2

func ErrInvalidArgument(name string, msg string) error

ErrInvalidArgument is a wrapper function for easier invalid argument error handling.

func GetOffsetN added in v0.2.2

func GetOffsetN(page, pageSize uint) (offset, n uint)

func GetPage added in v0.2.2

func GetPage(reqPage, reqPageSize uint32) (page, pageSize uint)

GetPage gets page and pageSize from request params.

func New

func New(config config.Config) (server.Plugin, error)

func RegisterClientServiceHandler

func RegisterClientServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterClientServiceHandler registers the http handlers for service ClientService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterClientServiceHandlerClient

func RegisterClientServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ClientServiceClient) error

RegisterClientServiceHandlerClient registers the http handlers for service ClientService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ClientServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ClientServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ClientServiceClient" to call the correct interceptors.

func RegisterClientServiceHandlerFromEndpoint

func RegisterClientServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterClientServiceHandlerFromEndpoint is same as RegisterClientServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterClientServiceHandlerServer

func RegisterClientServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ClientServiceServer) error

RegisterClientServiceHandlerServer registers the http handlers for service ClientService to "mux". UnaryRPC :call ClientServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterClientServiceServer

func RegisterClientServiceServer(s grpc.ServiceRegistrar, srv ClientServiceServer)

func RegisterPublishServiceHandler

func RegisterPublishServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterPublishServiceHandler registers the http handlers for service PublishService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterPublishServiceHandlerClient

func RegisterPublishServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PublishServiceClient) error

RegisterPublishServiceHandlerClient registers the http handlers for service PublishService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PublishServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PublishServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "PublishServiceClient" to call the correct interceptors.

func RegisterPublishServiceHandlerFromEndpoint

func RegisterPublishServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterPublishServiceHandlerFromEndpoint is same as RegisterPublishServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterPublishServiceHandlerServer

func RegisterPublishServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PublishServiceServer) error

RegisterPublishServiceHandlerServer registers the http handlers for service PublishService to "mux". UnaryRPC :call PublishServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterPublishServiceServer

func RegisterPublishServiceServer(s grpc.ServiceRegistrar, srv PublishServiceServer)

func RegisterSubscriptionServiceHandler

func RegisterSubscriptionServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterSubscriptionServiceHandler registers the http handlers for service SubscriptionService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterSubscriptionServiceHandlerClient

func RegisterSubscriptionServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SubscriptionServiceClient) error

RegisterSubscriptionServiceHandlerClient registers the http handlers for service SubscriptionService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SubscriptionServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SubscriptionServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "SubscriptionServiceClient" to call the correct interceptors.

func RegisterSubscriptionServiceHandlerFromEndpoint

func RegisterSubscriptionServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterSubscriptionServiceHandlerFromEndpoint is same as RegisterSubscriptionServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterSubscriptionServiceHandlerServer

func RegisterSubscriptionServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SubscriptionServiceServer) error

RegisterSubscriptionServiceHandlerServer registers the http handlers for service SubscriptionService to "mux". UnaryRPC :call SubscriptionServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterSubscriptionServiceServer

func RegisterSubscriptionServiceServer(s grpc.ServiceRegistrar, srv SubscriptionServiceServer)

Types

type Admin

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

Admin providers gRPC and HTTP API that enables the external system to interact with the broker.

func (*Admin) HookWrapper

func (a *Admin) HookWrapper() server.HookWrapper

func (*Admin) Load

func (a *Admin) Load(service server.Server) error

func (*Admin) Name

func (a *Admin) Name() string

func (*Admin) OnClosedWrapper

func (a *Admin) OnClosedWrapper(pre server.OnClosed) server.OnClosed

func (*Admin) OnSessionCreatedWrapper

func (a *Admin) OnSessionCreatedWrapper(pre server.OnSessionCreated) server.OnSessionCreated

func (*Admin) OnSessionResumedWrapper added in v0.2.2

func (a *Admin) OnSessionResumedWrapper(pre server.OnSessionResumed) server.OnSessionResumed

func (*Admin) OnSessionTerminatedWrapper

func (a *Admin) OnSessionTerminatedWrapper(pre server.OnSessionTerminated) server.OnSessionTerminated

func (*Admin) OnSubscribedWrapper

func (a *Admin) OnSubscribedWrapper(pre server.OnSubscribed) server.OnSubscribed

func (*Admin) OnUnsubscribedWrapper

func (a *Admin) OnUnsubscribedWrapper(pre server.OnUnsubscribed) server.OnUnsubscribed

func (*Admin) Unload

func (a *Admin) Unload() error

type Client

type Client struct {
	ClientId             string               `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
	Username             string               `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	KeepAlive            int32                `protobuf:"varint,3,opt,name=keep_alive,json=keepAlive,proto3" json:"keep_alive,omitempty"`
	Version              int32                `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"`
	RemoteAddr           string               `protobuf:"bytes,5,opt,name=remote_addr,json=remoteAddr,proto3" json:"remote_addr,omitempty"`
	LocalAddr            string               `protobuf:"bytes,6,opt,name=local_addr,json=localAddr,proto3" json:"local_addr,omitempty"`
	ConnectedAt          *timestamp.Timestamp `protobuf:"bytes,7,opt,name=connected_at,json=connectedAt,proto3" json:"connected_at,omitempty"`
	DisconnectedAt       *timestamp.Timestamp `protobuf:"bytes,8,opt,name=disconnected_at,json=disconnectedAt,proto3" json:"disconnected_at,omitempty"`
	SessionExpiry        uint32               `protobuf:"varint,9,opt,name=session_expiry,json=sessionExpiry,proto3" json:"session_expiry,omitempty"`
	MaxInflight          uint32               `protobuf:"varint,10,opt,name=max_inflight,json=maxInflight,proto3" json:"max_inflight,omitempty"`
	InflightLen          uint32               `protobuf:"varint,11,opt,name=inflight_len,json=inflightLen,proto3" json:"inflight_len,omitempty"`
	MaxQueue             uint32               `protobuf:"varint,12,opt,name=max_queue,json=maxQueue,proto3" json:"max_queue,omitempty"`
	QueueLen             uint32               `protobuf:"varint,13,opt,name=queue_len,json=queueLen,proto3" json:"queue_len,omitempty"`
	SubscriptionsCurrent uint32               `protobuf:"varint,14,opt,name=subscriptions_current,json=subscriptionsCurrent,proto3" json:"subscriptions_current,omitempty"`
	SubscriptionsTotal   uint32               `protobuf:"varint,15,opt,name=subscriptions_total,json=subscriptionsTotal,proto3" json:"subscriptions_total,omitempty"`
	PacketsReceivedBytes uint64               `protobuf:"varint,16,opt,name=packets_received_bytes,json=packetsReceivedBytes,proto3" json:"packets_received_bytes,omitempty"`
	PacketsReceivedNums  uint64               `protobuf:"varint,17,opt,name=packets_received_nums,json=packetsReceivedNums,proto3" json:"packets_received_nums,omitempty"`
	PacketsSendBytes     uint64               `protobuf:"varint,18,opt,name=packets_send_bytes,json=packetsSendBytes,proto3" json:"packets_send_bytes,omitempty"`
	PacketsSendNums      uint64               `protobuf:"varint,19,opt,name=packets_send_nums,json=packetsSendNums,proto3" json:"packets_send_nums,omitempty"`
	MessageDropped       uint64               `protobuf:"varint,20,opt,name=message_dropped,json=messageDropped,proto3" json:"message_dropped,omitempty"`
	// contains filtered or unexported fields
}

func (*Client) Descriptor deprecated

func (*Client) Descriptor() ([]byte, []int)

Deprecated: Use Client.ProtoReflect.Descriptor instead.

func (*Client) GetClientId

func (x *Client) GetClientId() string

func (*Client) GetConnectedAt

func (x *Client) GetConnectedAt() *timestamp.Timestamp

func (*Client) GetDisconnectedAt

func (x *Client) GetDisconnectedAt() *timestamp.Timestamp

func (*Client) GetInflightLen

func (x *Client) GetInflightLen() uint32

func (*Client) GetKeepAlive

func (x *Client) GetKeepAlive() int32

func (*Client) GetLocalAddr

func (x *Client) GetLocalAddr() string

func (*Client) GetMaxInflight

func (x *Client) GetMaxInflight() uint32

func (*Client) GetMaxQueue

func (x *Client) GetMaxQueue() uint32

func (*Client) GetMessageDropped

func (x *Client) GetMessageDropped() uint64

func (*Client) GetPacketsReceivedBytes

func (x *Client) GetPacketsReceivedBytes() uint64

func (*Client) GetPacketsReceivedNums

func (x *Client) GetPacketsReceivedNums() uint64

func (*Client) GetPacketsSendBytes

func (x *Client) GetPacketsSendBytes() uint64

func (*Client) GetPacketsSendNums

func (x *Client) GetPacketsSendNums() uint64

func (*Client) GetQueueLen

func (x *Client) GetQueueLen() uint32

func (*Client) GetRemoteAddr

func (x *Client) GetRemoteAddr() string

func (*Client) GetSessionExpiry

func (x *Client) GetSessionExpiry() uint32

func (*Client) GetSubscriptionsCurrent

func (x *Client) GetSubscriptionsCurrent() uint32

func (*Client) GetSubscriptionsTotal

func (x *Client) GetSubscriptionsTotal() uint32

func (*Client) GetUsername

func (x *Client) GetUsername() string

func (*Client) GetVersion

func (x *Client) GetVersion() int32

func (*Client) ProtoMessage

func (*Client) ProtoMessage()

func (*Client) ProtoReflect

func (x *Client) ProtoReflect() protoreflect.Message

func (*Client) Reset

func (x *Client) Reset()

func (*Client) String

func (x *Client) String() string

type ClientServiceClient

type ClientServiceClient interface {
	// List clients
	List(ctx context.Context, in *ListClientRequest, opts ...grpc.CallOption) (*ListClientResponse, error)
	// Get the client for given client id.
	// Return NotFound error when client not found.
	Get(ctx context.Context, in *GetClientRequest, opts ...grpc.CallOption) (*GetClientResponse, error)
	// Disconnect the client for given client id.
	Delete(ctx context.Context, in *DeleteClientRequest, opts ...grpc.CallOption) (*empty.Empty, error)
}

ClientServiceClient is the client API for ClientService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type ClientServiceServer

type ClientServiceServer interface {
	// List clients
	List(context.Context, *ListClientRequest) (*ListClientResponse, error)
	// Get the client for given client id.
	// Return NotFound error when client not found.
	Get(context.Context, *GetClientRequest) (*GetClientResponse, error)
	// Disconnect the client for given client id.
	Delete(context.Context, *DeleteClientRequest) (*empty.Empty, error)
	// contains filtered or unexported methods
}

ClientServiceServer is the server API for ClientService service. All implementations must embed UnimplementedClientServiceServer for forward compatibility

type Config

type Config struct {
	HTTP HTTPConfig `yaml:"http"`
	GRPC GRPCConfig `yaml:"grpc"`
}

Config is the configuration for the admin plugin.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration, and return an error if it is invalid.

type DeleteClientRequest

type DeleteClientRequest struct {
	ClientId     string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
	CleanSession bool   `protobuf:"varint,2,opt,name=clean_session,json=cleanSession,proto3" json:"clean_session,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteClientRequest) Descriptor deprecated

func (*DeleteClientRequest) Descriptor() ([]byte, []int)

Deprecated: Use DeleteClientRequest.ProtoReflect.Descriptor instead.

func (*DeleteClientRequest) GetCleanSession

func (x *DeleteClientRequest) GetCleanSession() bool

func (*DeleteClientRequest) GetClientId

func (x *DeleteClientRequest) GetClientId() string

func (*DeleteClientRequest) ProtoMessage

func (*DeleteClientRequest) ProtoMessage()

func (*DeleteClientRequest) ProtoReflect

func (x *DeleteClientRequest) ProtoReflect() protoreflect.Message

func (*DeleteClientRequest) Reset

func (x *DeleteClientRequest) Reset()

func (*DeleteClientRequest) String

func (x *DeleteClientRequest) String() string

type FilterSubscriptionRequest

type FilterSubscriptionRequest struct {

	// If set, only filter the subscriptions that belongs to the client.
	ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
	// filter_type indicates what kinds of topics are going to filter.
	// If there are multiple types, use ',' to separate. e.g : 1,2
	// There are 3 kinds of topic can be filtered, defined by SubFilterType:
	// 1 = System Topic(begin with '$')
	// 2 = Shared Topic
	// 3 = NonShared Topic
	FilterType string `protobuf:"bytes,2,opt,name=filter_type,json=filterType,proto3" json:"filter_type,omitempty"`
	// If 1 (SUB_MATCH_TYPE_MATCH_NAME), the server will return subscriptions which has the same topic name with request topic_name.
	// If 2 (SUB_MATCH_TYPE_MATCH_FILTER),the server will return subscriptions which match the request topic_name .
	// match_type must be set when filter_type is not empty.
	MatchType SubMatchType `protobuf:"varint,3,opt,name=match_type,json=matchType,proto3,enum=gmqtt.admin.api.SubMatchType" json:"match_type,omitempty"`
	// topic_name must be set when match_type is not zero.
	TopicName string `protobuf:"bytes,4,opt,name=topic_name,json=topicName,proto3" json:"topic_name,omitempty"`
	// The maximum subscriptions can be returned.
	Limit int32 `protobuf:"varint,5,opt,name=limit,proto3" json:"limit,omitempty"`
	// contains filtered or unexported fields
}

func (*FilterSubscriptionRequest) Descriptor deprecated

func (*FilterSubscriptionRequest) Descriptor() ([]byte, []int)

Deprecated: Use FilterSubscriptionRequest.ProtoReflect.Descriptor instead.

func (*FilterSubscriptionRequest) GetClientId

func (x *FilterSubscriptionRequest) GetClientId() string

func (*FilterSubscriptionRequest) GetFilterType

func (x *FilterSubscriptionRequest) GetFilterType() string

func (*FilterSubscriptionRequest) GetLimit

func (x *FilterSubscriptionRequest) GetLimit() int32

func (*FilterSubscriptionRequest) GetMatchType

func (x *FilterSubscriptionRequest) GetMatchType() SubMatchType

func (*FilterSubscriptionRequest) GetTopicName

func (x *FilterSubscriptionRequest) GetTopicName() string

func (*FilterSubscriptionRequest) ProtoMessage

func (*FilterSubscriptionRequest) ProtoMessage()

func (*FilterSubscriptionRequest) ProtoReflect

func (*FilterSubscriptionRequest) Reset

func (x *FilterSubscriptionRequest) Reset()

func (*FilterSubscriptionRequest) String

func (x *FilterSubscriptionRequest) String() string

type FilterSubscriptionResponse

type FilterSubscriptionResponse struct {
	Subscriptions []*Subscription `protobuf:"bytes,1,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"`
	// contains filtered or unexported fields
}

func (*FilterSubscriptionResponse) Descriptor deprecated

func (*FilterSubscriptionResponse) Descriptor() ([]byte, []int)

Deprecated: Use FilterSubscriptionResponse.ProtoReflect.Descriptor instead.

func (*FilterSubscriptionResponse) GetSubscriptions

func (x *FilterSubscriptionResponse) GetSubscriptions() []*Subscription

func (*FilterSubscriptionResponse) ProtoMessage

func (*FilterSubscriptionResponse) ProtoMessage()

func (*FilterSubscriptionResponse) ProtoReflect

func (*FilterSubscriptionResponse) Reset

func (x *FilterSubscriptionResponse) Reset()

func (*FilterSubscriptionResponse) String

func (x *FilterSubscriptionResponse) String() string

type GRPCConfig

type GRPCConfig struct {
	// Addr is the address that the gRPC server listen on.
	Addr string `yaml:"http_addr"`
}

GRPCConfig is the configuration for gRPC endpoint.

type GetClientRequest

type GetClientRequest struct {
	ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
	// contains filtered or unexported fields
}

func (*GetClientRequest) Descriptor deprecated

func (*GetClientRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetClientRequest.ProtoReflect.Descriptor instead.

func (*GetClientRequest) GetClientId

func (x *GetClientRequest) GetClientId() string

func (*GetClientRequest) ProtoMessage

func (*GetClientRequest) ProtoMessage()

func (*GetClientRequest) ProtoReflect

func (x *GetClientRequest) ProtoReflect() protoreflect.Message

func (*GetClientRequest) Reset

func (x *GetClientRequest) Reset()

func (*GetClientRequest) String

func (x *GetClientRequest) String() string

type GetClientResponse

type GetClientResponse struct {
	Client *Client `protobuf:"bytes,1,opt,name=client,proto3" json:"client,omitempty"`
	// contains filtered or unexported fields
}

func (*GetClientResponse) Descriptor deprecated

func (*GetClientResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetClientResponse.ProtoReflect.Descriptor instead.

func (*GetClientResponse) GetClient

func (x *GetClientResponse) GetClient() *Client

func (*GetClientResponse) ProtoMessage

func (*GetClientResponse) ProtoMessage()

func (*GetClientResponse) ProtoReflect

func (x *GetClientResponse) ProtoReflect() protoreflect.Message

func (*GetClientResponse) Reset

func (x *GetClientResponse) Reset()

func (*GetClientResponse) String

func (x *GetClientResponse) String() string

type HTTPConfig

type HTTPConfig struct {
	// Enable indicates whether to expose http endpoint.
	Enable bool `yaml:"enable"`
	// Addr is the address that the http server listen on.
	Addr string `yaml:"http_addr"`
}

HTTPConfig is the configuration for http endpoint.

type Indexer added in v0.2.2

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

Indexer provides a index for a ordered list that supports queries in O(1). All methods are not concurrency-safe.

func NewIndexer added in v0.2.2

func NewIndexer() *Indexer

NewIndexer is the constructor of Indexer.

func (*Indexer) GetByID added in v0.2.2

func (i *Indexer) GetByID(id string) *list.Element

GetByID returns the value for the given id. Return nil if not found. Notice: Any access to the return *list.Element also require the mutex, because the Set method can modify the Value for *list.Element when updating the Value for the same id. If the caller needs the Value in *list.Element, it must get the Value before the next Set is called.

func (*Indexer) Iterate added in v0.2.2

func (i *Indexer) Iterate(fn func(elem *list.Element), offset, n uint)

Iterate iterates at most n elements in the list begin from offset. Notice: Any access to the *list.Element in fn also require the mutex, because the Set method can modify the Value for *list.Element when updating the Value for the same id. If the caller needs the Value in *list.Element, it must get the Value before the next Set is called.

func (*Indexer) Len added in v0.2.2

func (i *Indexer) Len() int

Len returns the length of list.

func (*Indexer) Remove added in v0.2.2

func (i *Indexer) Remove(id string) *list.Element

Remove removes and returns the value for the given id. Return nil if not found.

func (*Indexer) Set added in v0.2.2

func (i *Indexer) Set(id string, value interface{})

Set sets the value for the id.

type ListClientRequest

type ListClientRequest struct {
	PageSize uint32 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
	Page     uint32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"`
	// contains filtered or unexported fields
}

func (*ListClientRequest) Descriptor deprecated

func (*ListClientRequest) Descriptor() ([]byte, []int)

Deprecated: Use ListClientRequest.ProtoReflect.Descriptor instead.

func (*ListClientRequest) GetPage

func (x *ListClientRequest) GetPage() uint32

func (*ListClientRequest) GetPageSize

func (x *ListClientRequest) GetPageSize() uint32

func (*ListClientRequest) ProtoMessage

func (*ListClientRequest) ProtoMessage()

func (*ListClientRequest) ProtoReflect

func (x *ListClientRequest) ProtoReflect() protoreflect.Message

func (*ListClientRequest) Reset

func (x *ListClientRequest) Reset()

func (*ListClientRequest) String

func (x *ListClientRequest) String() string

type ListClientResponse

type ListClientResponse struct {
	Clients    []*Client `protobuf:"bytes,1,rep,name=clients,proto3" json:"clients,omitempty"`
	TotalCount uint32    `protobuf:"varint,2,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"`
	// contains filtered or unexported fields
}

func (*ListClientResponse) Descriptor deprecated

func (*ListClientResponse) Descriptor() ([]byte, []int)

Deprecated: Use ListClientResponse.ProtoReflect.Descriptor instead.

func (*ListClientResponse) GetClients

func (x *ListClientResponse) GetClients() []*Client

func (*ListClientResponse) GetTotalCount

func (x *ListClientResponse) GetTotalCount() uint32

func (*ListClientResponse) ProtoMessage

func (*ListClientResponse) ProtoMessage()

func (*ListClientResponse) ProtoReflect

func (x *ListClientResponse) ProtoReflect() protoreflect.Message

func (*ListClientResponse) Reset

func (x *ListClientResponse) Reset()

func (*ListClientResponse) String

func (x *ListClientResponse) String() string

type ListSubscriptionRequest

type ListSubscriptionRequest struct {
	PageSize uint32 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
	Page     uint32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"`
	// contains filtered or unexported fields
}

func (*ListSubscriptionRequest) Descriptor deprecated

func (*ListSubscriptionRequest) Descriptor() ([]byte, []int)

Deprecated: Use ListSubscriptionRequest.ProtoReflect.Descriptor instead.

func (*ListSubscriptionRequest) GetPage

func (x *ListSubscriptionRequest) GetPage() uint32

func (*ListSubscriptionRequest) GetPageSize

func (x *ListSubscriptionRequest) GetPageSize() uint32

func (*ListSubscriptionRequest) ProtoMessage

func (*ListSubscriptionRequest) ProtoMessage()

func (*ListSubscriptionRequest) ProtoReflect

func (x *ListSubscriptionRequest) ProtoReflect() protoreflect.Message

func (*ListSubscriptionRequest) Reset

func (x *ListSubscriptionRequest) Reset()

func (*ListSubscriptionRequest) String

func (x *ListSubscriptionRequest) String() string

type ListSubscriptionResponse

type ListSubscriptionResponse struct {
	Subscriptions []*Subscription `protobuf:"bytes,1,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"`
	TotalCount    uint32          `protobuf:"varint,2,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"`
	// contains filtered or unexported fields
}

func (*ListSubscriptionResponse) Descriptor deprecated

func (*ListSubscriptionResponse) Descriptor() ([]byte, []int)

Deprecated: Use ListSubscriptionResponse.ProtoReflect.Descriptor instead.

func (*ListSubscriptionResponse) GetSubscriptions

func (x *ListSubscriptionResponse) GetSubscriptions() []*Subscription

func (*ListSubscriptionResponse) GetTotalCount

func (x *ListSubscriptionResponse) GetTotalCount() uint32

func (*ListSubscriptionResponse) ProtoMessage

func (*ListSubscriptionResponse) ProtoMessage()

func (*ListSubscriptionResponse) ProtoReflect

func (x *ListSubscriptionResponse) ProtoReflect() protoreflect.Message

func (*ListSubscriptionResponse) Reset

func (x *ListSubscriptionResponse) Reset()

func (*ListSubscriptionResponse) String

func (x *ListSubscriptionResponse) String() string

type PublishRequest

type PublishRequest struct {
	TopicName string `protobuf:"bytes,1,opt,name=topic_name,json=topicName,proto3" json:"topic_name,omitempty"`
	Payload   string `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	Qos       uint32 `protobuf:"varint,3,opt,name=qos,proto3" json:"qos,omitempty"`
	Retained  bool   `protobuf:"varint,4,opt,name=retained,proto3" json:"retained,omitempty"`
	// the following fields are using in v5 client.
	ContentType     string            `protobuf:"bytes,5,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
	CorrelationData string            `protobuf:"bytes,6,opt,name=correlation_data,json=correlationData,proto3" json:"correlation_data,omitempty"`
	MessageExpiry   uint32            `protobuf:"varint,7,opt,name=message_expiry,json=messageExpiry,proto3" json:"message_expiry,omitempty"`
	PayloadFormat   uint32            `protobuf:"varint,8,opt,name=payload_format,json=payloadFormat,proto3" json:"payload_format,omitempty"`
	ResponseTopic   string            `protobuf:"bytes,9,opt,name=response_topic,json=responseTopic,proto3" json:"response_topic,omitempty"`
	UserProperties  []*UserProperties `protobuf:"bytes,10,rep,name=user_properties,json=userProperties,proto3" json:"user_properties,omitempty"`
	// contains filtered or unexported fields
}

func (*PublishRequest) Descriptor deprecated

func (*PublishRequest) Descriptor() ([]byte, []int)

Deprecated: Use PublishRequest.ProtoReflect.Descriptor instead.

func (*PublishRequest) GetContentType

func (x *PublishRequest) GetContentType() string

func (*PublishRequest) GetCorrelationData

func (x *PublishRequest) GetCorrelationData() string

func (*PublishRequest) GetMessageExpiry

func (x *PublishRequest) GetMessageExpiry() uint32

func (*PublishRequest) GetPayload

func (x *PublishRequest) GetPayload() string

func (*PublishRequest) GetPayloadFormat

func (x *PublishRequest) GetPayloadFormat() uint32

func (*PublishRequest) GetQos

func (x *PublishRequest) GetQos() uint32

func (*PublishRequest) GetResponseTopic

func (x *PublishRequest) GetResponseTopic() string

func (*PublishRequest) GetRetained

func (x *PublishRequest) GetRetained() bool

func (*PublishRequest) GetTopicName

func (x *PublishRequest) GetTopicName() string

func (*PublishRequest) GetUserProperties

func (x *PublishRequest) GetUserProperties() []*UserProperties

func (*PublishRequest) ProtoMessage

func (*PublishRequest) ProtoMessage()

func (*PublishRequest) ProtoReflect

func (x *PublishRequest) ProtoReflect() protoreflect.Message

func (*PublishRequest) Reset

func (x *PublishRequest) Reset()

func (*PublishRequest) String

func (x *PublishRequest) String() string

type PublishServiceClient

type PublishServiceClient interface {
	// Publish message to broker
	Publish(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*empty.Empty, error)
}

PublishServiceClient is the client API for PublishService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type PublishServiceServer

type PublishServiceServer interface {
	// Publish message to broker
	Publish(context.Context, *PublishRequest) (*empty.Empty, error)
	// contains filtered or unexported methods
}

PublishServiceServer is the server API for PublishService service. All implementations must embed UnimplementedPublishServiceServer for forward compatibility

type SubFilterType

type SubFilterType int32
const (
	SubFilterType_SUB_FILTER_TYPE_SYS_UNSPECIFIED SubFilterType = 0
	SubFilterType_SUB_FILTER_TYPE_SYS             SubFilterType = 1
	SubFilterType_SUB_FILTER_TYPE_SHARED          SubFilterType = 2
	SubFilterType_SUB_FILTER_TYPE_NON_SHARED      SubFilterType = 3
)

func (SubFilterType) Descriptor

func (SubFilterType) Enum

func (x SubFilterType) Enum() *SubFilterType

func (SubFilterType) EnumDescriptor deprecated

func (SubFilterType) EnumDescriptor() ([]byte, []int)

Deprecated: Use SubFilterType.Descriptor instead.

func (SubFilterType) Number

func (SubFilterType) String

func (x SubFilterType) String() string

func (SubFilterType) Type

type SubMatchType

type SubMatchType int32
const (
	SubMatchType_SUB_MATCH_TYPE_MATCH_UNSPECIFIED SubMatchType = 0
	SubMatchType_SUB_MATCH_TYPE_MATCH_NAME        SubMatchType = 1
	SubMatchType_SUB_MATCH_TYPE_MATCH_FILTER      SubMatchType = 2
)

func (SubMatchType) Descriptor

func (SubMatchType) Enum

func (x SubMatchType) Enum() *SubMatchType

func (SubMatchType) EnumDescriptor deprecated

func (SubMatchType) EnumDescriptor() ([]byte, []int)

Deprecated: Use SubMatchType.Descriptor instead.

func (SubMatchType) Number

func (SubMatchType) String

func (x SubMatchType) String() string

func (SubMatchType) Type

type SubscribeRequest

type SubscribeRequest struct {
	ClientId      string          `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
	Subscriptions []*Subscription `protobuf:"bytes,2,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"`
	// contains filtered or unexported fields
}

func (*SubscribeRequest) Descriptor deprecated

func (*SubscribeRequest) Descriptor() ([]byte, []int)

Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead.

func (*SubscribeRequest) GetClientId

func (x *SubscribeRequest) GetClientId() string

func (*SubscribeRequest) GetSubscriptions

func (x *SubscribeRequest) GetSubscriptions() []*Subscription

func (*SubscribeRequest) ProtoMessage

func (*SubscribeRequest) ProtoMessage()

func (*SubscribeRequest) ProtoReflect

func (x *SubscribeRequest) ProtoReflect() protoreflect.Message

func (*SubscribeRequest) Reset

func (x *SubscribeRequest) Reset()

func (*SubscribeRequest) String

func (x *SubscribeRequest) String() string

type SubscribeResponse

type SubscribeResponse struct {

	// indicates whether it is a new subscription or the subscription is already existed.
	New []bool `protobuf:"varint,1,rep,packed,name=new,proto3" json:"new,omitempty"`
	// contains filtered or unexported fields
}

func (*SubscribeResponse) Descriptor deprecated

func (*SubscribeResponse) Descriptor() ([]byte, []int)

Deprecated: Use SubscribeResponse.ProtoReflect.Descriptor instead.

func (*SubscribeResponse) GetNew

func (x *SubscribeResponse) GetNew() []bool

func (*SubscribeResponse) ProtoMessage

func (*SubscribeResponse) ProtoMessage()

func (*SubscribeResponse) ProtoReflect

func (x *SubscribeResponse) ProtoReflect() protoreflect.Message

func (*SubscribeResponse) Reset

func (x *SubscribeResponse) Reset()

func (*SubscribeResponse) String

func (x *SubscribeResponse) String() string

type Subscription

type Subscription struct {
	TopicName         string `protobuf:"bytes,1,opt,name=topic_name,json=topicName,proto3" json:"topic_name,omitempty"`
	Id                uint32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"`
	Qos               uint32 `protobuf:"varint,3,opt,name=qos,proto3" json:"qos,omitempty"`
	NoLocal           bool   `protobuf:"varint,4,opt,name=no_local,json=noLocal,proto3" json:"no_local,omitempty"`
	RetainAsPublished bool   `protobuf:"varint,5,opt,name=retain_as_published,json=retainAsPublished,proto3" json:"retain_as_published,omitempty"`
	RetainHandling    uint32 `protobuf:"varint,6,opt,name=retain_handling,json=retainHandling,proto3" json:"retain_handling,omitempty"`
	ClientId          string `protobuf:"bytes,7,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
	// contains filtered or unexported fields
}

func (*Subscription) Descriptor deprecated

func (*Subscription) Descriptor() ([]byte, []int)

Deprecated: Use Subscription.ProtoReflect.Descriptor instead.

func (*Subscription) GetClientId

func (x *Subscription) GetClientId() string

func (*Subscription) GetId

func (x *Subscription) GetId() uint32

func (*Subscription) GetNoLocal

func (x *Subscription) GetNoLocal() bool

func (*Subscription) GetQos

func (x *Subscription) GetQos() uint32

func (*Subscription) GetRetainAsPublished

func (x *Subscription) GetRetainAsPublished() bool

func (*Subscription) GetRetainHandling

func (x *Subscription) GetRetainHandling() uint32

func (*Subscription) GetTopicName

func (x *Subscription) GetTopicName() string

func (*Subscription) ProtoMessage

func (*Subscription) ProtoMessage()

func (*Subscription) ProtoReflect

func (x *Subscription) ProtoReflect() protoreflect.Message

func (*Subscription) Reset

func (x *Subscription) Reset()

func (*Subscription) String

func (x *Subscription) String() string

type SubscriptionServiceClient

type SubscriptionServiceClient interface {
	// List subscriptions.
	List(ctx context.Context, in *ListSubscriptionRequest, opts ...grpc.CallOption) (*ListSubscriptionResponse, error)
	// Filter subscriptions, paging is not supported in this API.
	Filter(ctx context.Context, in *FilterSubscriptionRequest, opts ...grpc.CallOption) (*FilterSubscriptionResponse, error)
	// Subscribe topics for the client.
	Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (*SubscribeResponse, error)
	// Unsubscribe topics for the client.
	Unsubscribe(ctx context.Context, in *UnsubscribeRequest, opts ...grpc.CallOption) (*empty.Empty, error)
}

SubscriptionServiceClient is the client API for SubscriptionService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type SubscriptionServiceServer

type SubscriptionServiceServer interface {
	// List subscriptions.
	List(context.Context, *ListSubscriptionRequest) (*ListSubscriptionResponse, error)
	// Filter subscriptions, paging is not supported in this API.
	Filter(context.Context, *FilterSubscriptionRequest) (*FilterSubscriptionResponse, error)
	// Subscribe topics for the client.
	Subscribe(context.Context, *SubscribeRequest) (*SubscribeResponse, error)
	// Unsubscribe topics for the client.
	Unsubscribe(context.Context, *UnsubscribeRequest) (*empty.Empty, error)
	// contains filtered or unexported methods
}

SubscriptionServiceServer is the server API for SubscriptionService service. All implementations must embed UnimplementedSubscriptionServiceServer for forward compatibility

type UnimplementedClientServiceServer

type UnimplementedClientServiceServer struct {
}

UnimplementedClientServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedClientServiceServer) Delete

func (UnimplementedClientServiceServer) Get

func (UnimplementedClientServiceServer) List

type UnimplementedPublishServiceServer

type UnimplementedPublishServiceServer struct {
}

UnimplementedPublishServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedPublishServiceServer) Publish

type UnimplementedSubscriptionServiceServer

type UnimplementedSubscriptionServiceServer struct {
}

UnimplementedSubscriptionServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedSubscriptionServiceServer) List

func (UnimplementedSubscriptionServiceServer) Subscribe

func (UnimplementedSubscriptionServiceServer) Unsubscribe

type UnsafeClientServiceServer

type UnsafeClientServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeClientServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ClientServiceServer will result in compilation errors.

type UnsafePublishServiceServer

type UnsafePublishServiceServer interface {
	// contains filtered or unexported methods
}

UnsafePublishServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to PublishServiceServer will result in compilation errors.

type UnsafeSubscriptionServiceServer

type UnsafeSubscriptionServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeSubscriptionServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to SubscriptionServiceServer will result in compilation errors.

type UnsubscribeRequest

type UnsubscribeRequest struct {
	ClientId string   `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
	Topics   []string `protobuf:"bytes,2,rep,name=topics,proto3" json:"topics,omitempty"`
	// contains filtered or unexported fields
}

func (*UnsubscribeRequest) Descriptor deprecated

func (*UnsubscribeRequest) Descriptor() ([]byte, []int)

Deprecated: Use UnsubscribeRequest.ProtoReflect.Descriptor instead.

func (*UnsubscribeRequest) GetClientId

func (x *UnsubscribeRequest) GetClientId() string

func (*UnsubscribeRequest) GetTopics

func (x *UnsubscribeRequest) GetTopics() []string

func (*UnsubscribeRequest) ProtoMessage

func (*UnsubscribeRequest) ProtoMessage()

func (*UnsubscribeRequest) ProtoReflect

func (x *UnsubscribeRequest) ProtoReflect() protoreflect.Message

func (*UnsubscribeRequest) Reset

func (x *UnsubscribeRequest) Reset()

func (*UnsubscribeRequest) String

func (x *UnsubscribeRequest) String() string

type UserProperties

type UserProperties struct {
	K []byte `protobuf:"bytes,1,opt,name=K,proto3" json:"K,omitempty"`
	V []byte `protobuf:"bytes,2,opt,name=V,proto3" json:"V,omitempty"`
	// contains filtered or unexported fields
}

func (*UserProperties) Descriptor deprecated

func (*UserProperties) Descriptor() ([]byte, []int)

Deprecated: Use UserProperties.ProtoReflect.Descriptor instead.

func (*UserProperties) GetK

func (x *UserProperties) GetK() []byte

func (*UserProperties) GetV

func (x *UserProperties) GetV() []byte

func (*UserProperties) ProtoMessage

func (*UserProperties) ProtoMessage()

func (*UserProperties) ProtoReflect

func (x *UserProperties) ProtoReflect() protoreflect.Message

func (*UserProperties) Reset

func (x *UserProperties) Reset()

func (*UserProperties) String

func (x *UserProperties) String() string

Jump to

Keyboard shortcuts

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