keyvalue

package
v0.0.0-...-aece62e Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package keyvalue is generated code used to make or handle TChannel calls using Thrift.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTChanKeyValueServiceInheritedClient

func NewTChanKeyValueServiceInheritedClient(thriftService string, client thrift.TChanClient) *tchanKeyValueServiceClient

func NewTChanKeyValueServiceServer

func NewTChanKeyValueServiceServer(handler TChanKeyValueService) thrift.TChanServer

NewTChanKeyValueServiceServer wraps a handler for TChanKeyValueService so it can be registered with a thrift.Server.

Types

type KeyValueServiceConfiguration

type KeyValueServiceConfiguration struct {
	// Get holds the forwarding configuration for the Get endpoint defined in the service
	Get *KeyValueServiceGetConfiguration
	// GetAll holds the forwarding configuration for the GetAll endpoint defined in the service
	GetAll *KeyValueServiceGetAllConfiguration
	// Set holds the forwarding configuration for the Set endpoint defined in the service
	Set *KeyValueServiceSetConfiguration
}

KeyValueServiceConfiguration contains the forwarding configuration for the KeyValueService service. It has a field for every endpoint defined in the service. In this field the endpoint specific forward configuration can be stored. Populating these fields is optional, default behaviour is to call the service implementation locally to the process where the call came in.

type KeyValueServiceGetAllConfiguration

type KeyValueServiceGetAllConfiguration struct {
	// Key is a closure that generates a routable key based on the parameters of the incomming request.
	Key func(ctx thrift.Context, keys []string) (string, error)
}

KeyValueServiceGetAllConfiguration contains the configuration on how to route calls to the thrift endpoint KeyValueService::GetAll.

type KeyValueServiceGetConfiguration

type KeyValueServiceGetConfiguration struct {
	// Key is a closure that generates a routable key based on the parameters of the incomming request.
	Key func(ctx thrift.Context, key string) (string, error)
}

KeyValueServiceGetConfiguration contains the configuration on how to route calls to the thrift endpoint KeyValueService::Get.

type KeyValueServiceSetConfiguration

type KeyValueServiceSetConfiguration struct {
	// Key is a closure that generates a routable key based on the parameters of the incomming request.
	Key func(ctx thrift.Context, key string, value string) (string, error)
}

KeyValueServiceSetConfiguration contains the configuration on how to route calls to the thrift endpoint KeyValueService::Set.

type RingpopKeyValueServiceAdapter

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

func (*RingpopKeyValueServiceAdapter) Get

func (a *RingpopKeyValueServiceAdapter) Get(ctx thrift.Context, key string) (r string, err error)

Get satisfies the TChanKeyValueService interface. This function uses the configuration for Get to determine the host to execute the call on. When it decides the call needs to be executed in the current process it will forward the invocation to its local implementation.

func (*RingpopKeyValueServiceAdapter) GetAll

func (a *RingpopKeyValueServiceAdapter) GetAll(ctx thrift.Context, keys []string) (r []string, err error)

GetAll satisfies the TChanKeyValueService interface. This function uses the configuration for GetAll to determine the host to execute the call on. When it decides the call needs to be executed in the current process it will forward the invocation to its local implementation.

func (*RingpopKeyValueServiceAdapter) GetLocalClient

func (a *RingpopKeyValueServiceAdapter) GetLocalClient() interface{}

GetLocalClient satisfies the ClientFactory interface of ringpop-go/router

func (*RingpopKeyValueServiceAdapter) MakeRemoteClient

func (a *RingpopKeyValueServiceAdapter) MakeRemoteClient(client thrift.TChanClient) interface{}

MakeRemoteClient satisfies the ClientFactory interface of ringpop-go/router

func (*RingpopKeyValueServiceAdapter) Set

func (a *RingpopKeyValueServiceAdapter) Set(ctx thrift.Context, key string, value string) (err error)

Set satisfies the TChanKeyValueService interface. This function uses the configuration for Set to determine the host to execute the call on. When it decides the call needs to be executed in the current process it will forward the invocation to its local implementation.

type TChanKeyValueService

type TChanKeyValueService interface {
	Get(ctx thrift.Context, key string) (string, error)
	GetAll(ctx thrift.Context, keys []string) ([]string, error)
	Set(ctx thrift.Context, key string, value string) error
}

TChanKeyValueService is the interface that defines the server handler and client interface.

func NewRingpopKeyValueServiceAdapter

func NewRingpopKeyValueServiceAdapter(
	impl TChanKeyValueService,
	rp ringpop.Interface,
	ch *tchannel.Channel,
	config KeyValueServiceConfiguration,
) (TChanKeyValueService, error)
  Set: &KeyValueServiceSetConfiguration: {
    Key: func(ctx thrift.Context, key string, value string) (shardKey string, err error) {
      return "calculated-shard-key", nil
    },
  },
},

) server.Register(NewTChanKeyValueServiceServer(adapter))

func NewTChanKeyValueServiceClient

func NewTChanKeyValueServiceClient(client thrift.TChanClient) TChanKeyValueService

NewTChanKeyValueServiceClient creates a client that can be used to make remote calls.

Jump to

Keyboard shortcuts

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