serialize

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

Functional requirements

Request, Close events for the same Connection.ID should be executed in network service chain serially.

Implementation

serializeServer, serializeClient

Serialize chain elements uses multi executor and stores per-id executor in the Request context.
NOTE: we don't pass executor to the Close context because it is very strange to plan events on already closed connection. Please don't do it.

Correct event firing chain element example:

func (s *eventServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) {
	executor := serializectx.Executor(ctx, request.GetConnection().GetId())
	go func() {
		executor.AsyncExec(func() {
			_, _ = next.Server(ctx).Request(serializectx.WithExecutor(context.TODO(), executor), request)
		})
	}()

	conn, err := next.Server(ctx).Request(ctx, request)
	if err != nil {
		return nil, err
	}

	go func() {
		executor.AsyncExec(func() {
			// We don't pass executor to the Close context. Please don't do it.
			_, _ = next.Server(ctx).Close(context.TODO(), conn)
		})
	}()

	return conn, nil
}

Documentation

Overview

Package serialize provides chain elements for serial Request, Close event processing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

NewClient returns a new serialize client chain element

func NewServer

NewServer returns a new serialize server chain element

Types

This section is empty.

Jump to

Keyboard shortcuts

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