func (server *PortServer) Save(stream proto.Storage_SaveServer) error {
	ctx := stream.Context()

	if err := func() error {
		for {
			select {
			case <-ctx.Done():
				return ctx.Err()
			default:
			}

			pair, err := stream.Recv()
			if errors.Is(err, io.EOF) {
				break
			}

			if err != nil {
				return err
			}

			server.PortStorage.Save(pair.Id, pair.Port)
		}

		return nil
	}(); err != nil {
		return status.Errorf(codes.Internal, "unexpected error: %v", err)
	}

	return stream.SendAndClose(new(empty.Empty))
}
// Save is a server-streaming RPC to store ports to the repository.
Save is a server-streaming RPC to store ports to the repository.
// Save is a server - streaming RPC to store ports to the repository .
func (server *PortServer) Save(stream proto.Storage_SaveServer) error {
	ctx := stream.Context()
	if err := func() error {
		for {
			select {
			case <-ctx.Done():
				return ctx.Err()
			default:
			}
			pair, err := stream.Recv()
			if errors.Is(err, io.EOF) {
				break
			}
			if err != nil {
				return err
			}
			server.PortStorage.Save(pair.Id, pair.Port)
		}
		return nil
	}(); err != nil {
		return status.Errorf(codes.Internal, "unexpected error: %v", err)
	}
	return stream.SendAndClose(new(empty.Empty))
}
func ( server * PortServer ) Save ( stream proto . Storage_SaveServer ) error { ctx := stream . Context ( ) if err := func ( ) error { for { select { case <- ctx . Done ( ) : return ctx . Err ( ) default : } pair , err := stream . Recv ( ) if errors . Is ( err , io . EOF ) { break } if err != nil { return err } server . PortStorage . Save ( pair . Id , pair . Port ) } return nil } ( ) ; err != nil { return status . Errorf ( codes . Internal , " " , err ) } return stream . SendAndClose ( new ( empty . Empty ) ) }
Save is a server-streaming RPC to store ports to the repository.
Save is a server - streaming RPC to store ports to the repository .